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
 

 

Mapping a char. var. in REXX with cobol numeric var.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Thu Jun 12, 2008 7:38 pm    Post subject: Mapping a char. var. in REXX with cobol numeric var.
Reply with quote

Hi All,

Here's the problem scenario :
In my code I am taking value from user's terminal as n1,n2 & n3.

In n1 & n2 I am passing a 2 digit number & in n3 I am passing a 10 digit number. All these number are to be written into a file which has a mapped copybook with variables defined as 999,9(5),s9(10).

Here I am bound to have these numbers being written in the above specified format that is n1 -> file-field1 (as 999),n2 -> file-field2 (as 9(5)) & n3 -> file-field3 (as s9(10)).

Currently I am facing following issues :
1)As how can I convert the input n variable data into the cobol numeric presentation so that same copybook format can be followed while writing.

2) For any field if the rexx input is smaller then the allocated space then the leading spaces should be put as zero while writing the data into the output file. ( as for 999 if the input is only one digit number then leading two digits should be put as zero)
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Thu Jun 12, 2008 10:27 pm    Post subject: Reply to: Mapping a char. var. in REXX with cobol numeric va
Reply with quote

Usually the RIGHT function will work.
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Fri Jun 13, 2008 9:17 am    Post subject: Reply to: Mapping a char. var. in REXX with cobol numeric va
Reply with quote

Thanks Superk. This will resolve the second part of my query.
Can you please help me out on my first issue.
Back to top
View user's profile Send private message
ajaypmenon

New User


Joined: 30 Mar 2007
Posts: 21
Location: North Carolina

PostPosted: Fri Jun 13, 2008 10:52 pm    Post subject: Write a subroutine in COBOL to handle it.
Reply with quote

Read it as a alphanumeric field. Redefine it and use it as numeric.

just a sample.

pic1 pic X(5)
pic2 redefines pic1. make it an array of 1 byte each

for i = 1 to 5
if pic2(i) not numeric
move pic2(1,i-1) to a numeric field and use it.
return
end-if
end
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Mon Jun 16, 2008 11:13 am    Post subject: Reply to: Mapping a char. var. in REXX with cobol numeric va
Reply with quote

Hi ajaypmenon,

Thanks for the input.
But I don't know how your solution is related to the given problem, as the code is to be written under REXX and not in COBOL. icon_question.gif
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Mon Jun 16, 2008 6:04 pm    Post subject:
Reply with quote

Hi all,

One of my queries under this thread is still unanswered .

Quote:
1)As how can I convert the input n variable data into the Cobol numeric presentation so that same copybook format can be followed while writing.


Please look at the top for complete Problem Description.

Can anyone please help me out on this.
If required I may elaborate the issue further more for clarification.
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Mon Jun 16, 2008 6:18 pm    Post subject:
Reply with quote

abhishekmdwivedi wrote:
If required I may elaborate the issue further more for clarification.


Yes, I think you need to. Keep in mind that not all of us speak in COBOL.
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Mon Jun 16, 2008 7:09 pm    Post subject: Reply to: Mapping a char. var. in REXX with cobol numeric va
Reply with quote

Hi all,

Here's the Problem Elaboration :

I have a REXX code which creates a file with following data :

1) AcctNo
2) TransID
3) UniID

Following code is used to take data from user and write the same into a output file :
Code:

SAY " PLEASE PROVIDE THE ACCOUNT NO. : "
PULL ANO                               
SAY " PLEASE PROVIDE THE TRANSID : "
PULL TID                               
SAY " PLEASE PROVIDE THE UNIID : "   
PULL UID                                 
PUSH ANO||TID||UID             
"EXECIO 1 DISKW OUTDS(FINIS"           


The given file is then feed into a production COBOL program which uses following copybook specification for reading the file:

Code:

ANO PIC S9(10)
TRANSID PIC 9(5)
UID PIC 999


Currently I want the values taken from USER through the REXX being converted to the above copybook specification as :

ANO (Var. in REXX) -> (Maps to) ANO PIC S9(10)
TRANSID(Var. in REXX) -> (Maps to) TRANSID PIC 9(5)
UID(Var. in REXX) -> (Maps to) UID PIC 999

As the production COBOL code cannot be modified I want this mapping in REXX.

Hope this will help in understanding the issue.
Back to top
View user's profile Send private message
ajaypmenon

New User


Joined: 30 Mar 2007
Posts: 21
Location: North Carolina

PostPosted: Mon Jun 16, 2008 7:26 pm    Post subject:
Reply with quote

Hi Abhishek,
Sorry i could not understand the requirement.

pull ano
ano = strip(ano)
len = length(ano)
ano = copies('0',10-len) || ano

if ano is entered as '345'
output will be 0000000345

lly all can be modifed to have its expected size. Hope this helps.

Thanks,
Ajay
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Mon Jun 16, 2008 7:43 pm    Post subject: Reply to: Mapping a char. var. in REXX with cobol numeric va
Reply with quote

Hi Ajay,

Thanks a lot for the update.
The code will work fine for variable 999 * 9(5) , but will this code map the values to a S9(10) variable correctly.....???
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1218
Location: Israel

PostPosted: Mon Jun 16, 2008 7:50 pm    Post subject:
Reply with quote

Code:
ano = strip(ano)
len = length(ano)
ano = copies('0',10-len) || ano

if ano is entered as '345'
output will be 0000000345


The same result can be obtained with:
Code:
ano = Right(ano,10,'0')


The complete code could look like that:
Code:
SAY " PLEASE PROVIDE THE ACCOUNT NO. : "
PULL ANO                               
SAY " PLEASE PROVIDE THE TRANSID : "
PULL TID                               
SAY " PLEASE PROVIDE THE UNIID : "   
PULL UID                                 
QUEUE RIGHT(ANO,10,'0') || RIGHT(TID,5,'0') || RIGHT(UID,3,'0')
"EXECIO 1 DISKW OUTDS(FINIS"


ANO value will be unsigned, COBOL will accept that.
Back to top
View user's profile Send private message
ajaypmenon

New User


Joined: 30 Mar 2007
Posts: 21
Location: North Carolina

PostPosted: Mon Jun 16, 2008 7:51 pm    Post subject:
Reply with quote

Hi Abhishek,
If its not having negative values, it will work properly. This is always an absolute value.

Thanks,
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Thu Jun 19, 2008 11:25 am    Post subject: Reply to: Mapping a char. var. in REXX with cobol numeric va
Reply with quote

Hi,

This is how the current production file looks like:

Code:
00001006.qÍà&.


And here is the file which I created through given code :

Code:
000010060987544500


here 00001 - TID (copybook : TID pic 9(5)) - matches production file format
006 - UID (Copybook : UID pic 999) - matches production file format
987544500 - ANO (Copybook : ANO pic s9(10)) - Unmatched format

This is what I asked earlier as whether the given code will work for S9(10) variable or not ???

Can anyone please suggest on this problem.

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

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Thu Jun 19, 2008 11:29 am    Post subject:
Reply with quote

Sorry, the ANO variable is of type PIC S9(10) comp-3. Please ignore the above info. on that variable.
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: Thu Jun 19, 2008 12:14 pm    Post subject:
Reply with quote

Hello,

The value shown "0987544500" is not a comp-3 (packed-decimal) value. To be a valid comp-3 value, the low-order half-byte must be a C, D, or F sign.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Jun 19, 2008 12:15 pm    Post subject: Reply to: Mapping a char. var. in REXX with cobol numeric va
Reply with quote

there is no such thing as mapping in rexx.....
in rexx anything is a char string

but You can convert string representing a number to the proper cobol representation

for example

the rexx expression
Code:
d2c(1,4)  will give as a result four bytes containing x"00000001" which is the cobol comp of a positive one

in the same way
Code:
d2c(-1,4) will give as a result four bytes containing x"ffffffff" which is the cobol comp of a negative one

the following code snippet will give the cobol representation of a packed number

call format
Code:
packed = pack(number,lenght)


Code:

/* */
pack: procedure
    parse arg numb , leng
   sign = left(numb,1)
   if    sign = "-"  then do
      sign = "D"
      numb = substr(numb,2)
   end
   else ,
   if    sign = "+"  then do
      sign = "C"
      numb = substr(numb,2)
   end
   else ,
      sign = "C"
   size = leng * 2 - 1
   temp = right(numb,size,"0") || sign
   pack = x2c(temp)
   return pack
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Thu Jun 19, 2008 12:22 pm    Post subject:
Reply with quote

Hi Dick,

Thanks for the reply.

Quote:
The value shown "0987544500" is not a comp-3 (packed-decimal) value.


This is what I am saying. The file which i created using the REXX is not populating the value "0987544500" as packed-decimal in the file , If you check I have given a file detail :

Code:
00001006.qÍà&.


which is current correct production file. I want that REXX code to write a Packed-Decimal format into the file.

Please look into the chain of discussion for problem scenario.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Jun 19, 2008 12:30 pm    Post subject: Reply to: Mapping a char. var. in REXX with cobol numeric va
Reply with quote

Quote:
I want that REXX code to write a Packed-Decimal format into the file.



REXX will not do it on its own... You must do it!

that' s what the code snipped I posted does icon_cool.gif
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Thu Jun 19, 2008 2:10 pm    Post subject:
Reply with quote

Quote:

REXX will not do it on its own... You must do it!

that' s what the code snipped I posted does


Got that man !!! icon_idea.gif
Thanks for the suggestion . And yup, the code works fine now...
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Thu Jun 19, 2008 2:12 pm    Post subject:
Reply with quote

All of you, thanks a lot for your participation. icon_smile.gif
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 -> CLIST & REXX All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am


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