Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

HELP !!! Picture (PIC) Clause padding...

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rohan agrawal

New User


Joined: 20 Feb 2009
Posts: 6
Location: India

PostPosted: Fri Mar 27, 2009 2:50 pm    Post subject: HELP !!! Picture (PIC) Clause padding...
Reply with quote

Hello friends,

I need to have a PIC clause value padded with '0'.

The problem is like, I have a PIC 9(7) clause and want to get a user input value stored into that. If supplied value is less than 7 char, then the value should be padded with '0' to occupy all 7 digits.

Example-

User Supplied Value :- 1234
Padded Value:- 0001234

This is just an ID no. I will not be using it for sign or any calculation purpose.
Please help out on this issue. I need a solution urgently.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Mar 27, 2009 3:05 pm    Post subject:
Reply with quote

so urgently that you post in two different web sites?

why don't you read the answer on the other one.
actually, this is a rookie question and this site has a rookie forum.
Back to top
View user's profile Send private message
rohan agrawal

New User


Joined: 20 Feb 2009
Posts: 6
Location: India

PostPosted: Fri Mar 27, 2009 4:04 pm    Post subject:
Reply with quote

Thanks for the information but if you check out the answer on the other website, its quite unclear.

It was quite urgent. This is the reason why I posted on two websites.

Thanks for your help anyways.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Mar 27, 2009 4:09 pm    Post subject:
Reply with quote

You didn't exactly help your own case, either. You say
Quote:
The problem is like, I have a PIC 9(7) clause and want to get a user input value stored into that. If supplied value is less than 7 char, then the value should be padded with '0' to occupy all 7 digits.
without specifying where the user input is coming from -- ACCEPT statement? File read?

When you can't provide enough basic information for someone to determine how to help you, don't blame others for your shortcomings. And a voluntary web forum is not the best way to get urgent help -- since people may or may not be reading your question when you need your help. For urgent issues, I recommend you consult people at your own site first.
Back to top
View user's profile Send private message
rohan agrawal

New User


Joined: 20 Feb 2009
Posts: 6
Location: India

PostPosted: Fri Mar 27, 2009 5:14 pm    Post subject:
Reply with quote

The input is coming through CICS screen via ACCEPT statement.

Is the the information sufficient now ?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Mar 27, 2009 5:17 pm    Post subject:
Reply with quote

*sigh*

data layout, code that you are using to manipulate the data?

same question on other forum.
Back to top
View user's profile Send private message
rohan agrawal

New User


Joined: 20 Feb 2009
Posts: 6
Location: India

PostPosted: Fri Mar 27, 2009 5:23 pm    Post subject:
Reply with quote

Quote:
When you can't provide enough basic information for someone to determine how to help you, don't blame others for your shortcomings.


I won't argue about it. But this is not a correct way of asking information. Since it is a voluntary web-forum, I haven't put compulsion on giving answer. If some1 is willing to answer, their suggestions are welcomed. But that was not a way of answering. Its great to see, the way Senior member treat newbies here.

FYI: I too am a volunteer in many of the open-source projects and moderator in some of them including forums. But quite new in mainframe technology. And never expected this type of reply in this forum.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Mar 27, 2009 5:40 pm    Post subject:
Reply with quote

Since you mention CICS look at BIF DEEDIT in the CICS Language Reference (manuals link at the top of the page). However, I don't know about the ACCEPT -- SEND MAP and RECEIVE MAP are the usual ways of interacting with a terminal in CICS.

The more urgently you request the information, the less likely you make it that you'll get your reply in a timely fashion. Especially since there is a specific CICS forum here which you didn't bother to use, instead referring to the COBOL forum which includes much more than just CICS. And especially since you didn't bother to provide the basic data such as the environment, what you've tried that didn't work, the variable definition, the precise PROCEDURE DIVISION statement(s) used, and any error messages that resulted from your failed attempts. As I said earlier, provide the basic data and your chances of getting a good answer improve. Tell us something doesn't work and your odds of getting good answers goes way down.

And your original statement
Quote:

I need to have a PIC clause value padded with '0'.
can be answered by "use PIC 9 for as many digits as you need -- when you move a numeric value into the field, it will be right justified and left zero filled." So don't try to say you provided enough data to resolve your issue.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Mar 27, 2009 5:51 pm    Post subject: Reply to: HELP !!! Picture (PIC) Clause padding...
Reply with quote

Quote:
The input is coming through CICS screen via ACCEPT statement.


icon_eek.gif icon_eek.gif icon_eek.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Mar 27, 2009 10:05 pm    Post subject:
Reply with quote

Hello,

There may still more here than has been posted. . . icon_confused.gif

Unless some kind of redefines is at work, or some kind of reference modification that was coded wrong, i'm not sure how one gets a value into a 9(7) field that is not zero padded.
Quote:
User Supplied Value :- 1234
Padded Value:- 0001234
I also don't know how to get the minus sign in the field with the 9(7) definition.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Mar 28, 2009 5:34 am    Post subject:
Reply with quote

If you don't use it, why don't you drop the minus sign? Try:
Code:
05  IP-VAL     PIC X(11).
05  OP-VAL     PIC 9(07).

COMPUTE OP-VAL = FUNCTION NUMVAL(IP-VAL)
Back to top
View user's profile Send private message
rohan agrawal

New User


Joined: 20 Feb 2009
Posts: 6
Location: India

PostPosted: Sun Mar 29, 2009 1:27 pm    Post subject: Reply to: HELP !!! Picture (PIC) Clause padding...
Reply with quote

Actually the sign is not minus. It was a dash after colon. " :- "
Sorry for that confusion. icon_sad.gif

What I need is a numeric value to be accepted, say into-
CUST-ID PIC 9(7).
Suppose if entered value is 1234. The result should be 0001234 into another variable say
CUST-NO PIC 9(7).


FYI, Robert:

Quote:
when you move a numeric value into the field, it will be right justified and left zero filled."

I have already tried that but it is not working.


Quote:
Especially since there is a specific CICS forum here which you didn't bother to use, instead referring to the COBOL forum which includes much more than just CICS.

ROBERT, I just mentioned that input is coming through a CICS screen. I never said that I want to do all this using CICS.


Quote:
So don't try to say you provided enough data to resolve your issue.

If you needed some detailed information, you could have said it in the forum instead of pointing towards it in a rough manner.
So I request you, kindly don't post your replies in this topic. There are a lot of other topics you can deal with. U're not forced to answer.
Back to top
View user's profile Send private message
rohan agrawal

New User


Joined: 20 Feb 2009
Posts: 6
Location: India

PostPosted: Sun Mar 29, 2009 1:35 pm    Post subject:
Reply with quote

mmwife wrote:
If you don't use it, why don't you drop the minus sign? Try:
Code:
05  IP-VAL     PIC X(11).
05  OP-VAL     PIC 9(07).

COMPUTE OP-VAL = FUNCTION NUMVAL(IP-VAL)


Thanks for your reply, Mmwife. And apology for the confusion created because of '-'. It is not minus, it was intented to be dash.

But due to some restrictions, I need IP-VAL and OP-VAL to be Numeric picture clause only.

i.e.

05 IP-VAL PIC 9(7).
05 OP-VAL PIC 9(7).

And if the value supplied to the IP-VAL is 1234, it should be moved into OP-VAL as 0001234.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sun Mar 29, 2009 8:04 pm    Post subject: Reply to: HELP !!! Picture (PIC) Clause padding...
Reply with quote

This code will right-justify a value of '1234bbb' in IP-VALUE into OP-VALUE as a value 0001234. Note that 'b' represents a blank/space.

Code:

03  IP-VALUE PIC 9(07).
03  OP-VALUE PIC 9(07).
03  SUB-01 PIC 9(04) BINARY.
03  SUB-02 PIC 9(04) BINARY.

MOVE '1234' TO IP-VALUE (1:).
MOVE ZERO TO OP-VALUE.
MOVE LENGTH OF IP-VALUE TO SUB-01.
MOVE SUB-01 TO SUB-02.

PERFORM UNTIL SUB-01 < 1
    IF  IP-VALUE (SUB-01:1) NUMERIC
        MOVE IP-VALUE (SUB-01:1) TO OP-VALUE (SUB-02:1)
        SUBTRACT 1 FROM SUB-02
    END-IF
    SUBTRACT 1 FROM SUB-01
END-PERFORM.

HTH....

Regards,
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Mar 29, 2009 8:52 pm    Post subject:
Reply with quote

Hi Rohan,

You said:
Quote:
Thanks for your reply, Mmwife. And apology for the confusion created because of '-'. It is not minus, it was intented to be dash.


Then try this:
Code:
INSPECT IP-VAL CONVERTING ':-' TO '  '
COMPUTE OP-VAL = FUNCTION NUMVAL(IP-VAL)

You may have to move IP-VAL to a work area if you need to preserve the orig value.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Sun Mar 29, 2009 10:05 pm    Post subject:
Reply with quote

As mentioned before, EXEC CICS BIF DEEDIT will allow you to format an input value into a numeric field. You could also use FUNCTION NUMVAL to format the value. You also could use reference modification to move one character at a time into a zero-filled variable. So you've been provided at least three separate ways to accomplish your purported goal.

Furthermore, you could have mentioned at the first that you're using CICS -- that impacts the available commands and processes that can be used.

You also haven't said what you've tried, nor the error message(s) you got with what you tried, nor why the provided solutions won't meet your needs. These are critical details that you are not providing.

You also managed to inject a spurious minus sign into your post which is misleading and another detail issue.

You have not explained why you are using a non-standard method of getting data into a CICS program (ACCEPT) instead of READ MAP or passing data with the transaction invocation. If you go over the posts, you will note there's a lot of raised eyebrows over this nonstandard method, as well.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts Padding with variable number of SPACE... cybertaurean SYNCSORT 7 Wed Oct 28, 2015 11:22 pm
No new posts [SQL0029] INTO clause missing from em... HABBIE DB2 2 Fri Sep 04, 2015 3:54 pm
No new posts 3-D Table with nested DEPENDING ON Cl... VivekKhanna COBOL Programming 5 Sat Aug 08, 2015 11:18 pm
No new posts when=group clause: question about the... tuxama DFSORT/ICETOOL 2 Thu Mar 26, 2015 12:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us