REXX code to extract a field from a file



IBM's Command List programming language & Restructured Extended Executor

REXX code to extract a field from a file

Postby munnu » Fri Jan 23, 2009 9:40 am

Hi,
I need a REXX code to extract all the fields starting with "EDI-" from a cobol program.
can anyone provide me the required code??

Thanks,
Munnu
munnu
 
Posts: 6
Joined: Tue Dec 30, 2008 11:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: REXX code to extract a field from a file

Postby expat » Mon Jan 26, 2009 5:36 pm

Your request is not clear. Is EDI a COBOL field name or does EDI appear in the actual data.
You need to show us what the records look like, and the locations of the fields that you need to extract
expat
 
Posts: 459
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 8 times

Re: REXX code to extract a field from a file

Postby munnu » Tue Jan 27, 2009 6:42 pm

Hi,
these "EDI-" fields are defined in a copybook and my program uses this copybook and also these "EDI-" feilds (not all EDI- fields that are defined in the copybook)are used explicitly.These fields dont have any fixed position to identify. I just want to get all those variables starting with "EDI-".

the pgm lokks like

MOVE EDI-444A-SR-CATEGORY TO WS-CLAIM-TYPE
MOVE EDI-499A-CL-ROUTED-TO TO WS-WLC-LOCATION-CODE
PERFORM
VARYING WS-TABLE-NDX FROM WS-NUM-1 BY WS-NUM-1
UNTIL WS-TABLE-NDX > WS-NUM-5
IF EDI-461L-CONDITION-CODE(WS-TABLE-NDX) = WS-LIT-02
SET DDC-CD-WRKRS-COMP-REQ
TO TRUE

Thanks,
Munnu
munnu
 
Posts: 6
Joined: Tue Dec 30, 2008 11:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: REXX code to extract a field from a file

Postby dick scherrer » Wed Jan 28, 2009 5:33 am

Hello,

What do you want as "output" from your process?

You mention a copybook, but the code posted shows some procedure division code?

Please post some sample output and explain the rules for selecting that particular output.

Also, please keep in mind that while your requirement is completely clear to you, it may not be to others who would like to help.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: REXX code to extract a field from a file

Postby munnu » Wed Jan 28, 2009 9:42 am

Yes, I just want to retrieve all "EDI-" variables that are used in the procedure division code without dupclicate. ie; theEDI- variables that are used in two different places in the procedure division should not be repeatedly retrieved after REXX execution.
Regarding copybook I meant that all these "EDI-" variables are defined in a copybook which is included in my pgm by the statement "copy EBSIDC".
EBSIDC is the copybook.

The output should look like:
All the EDI- variables extracted to a file as

EDI-444A-SR-CATEGORY
EDI-499A-CL-ROUTED-TO
EDI-499A-ROUTED-LIC
EDI-499A-ROUTED-NO
......

Please get back to me if my requirement is not clear.

Thanks,
Munnu
munnu
 
Posts: 6
Joined: Tue Dec 30, 2008 11:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: REXX code to extract a field from a file

Postby dick scherrer » Wed Jan 28, 2009 9:56 am

Hello,

Please get back to me if my requirement is not clear.
We're getting closer :)

Is it possible that anything other than fields in that copybook could begin with "EDI-"?

I'm not sure if this would help, but the info you want is available in the cobol compile cross reference. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: REXX code to extract a field from a file

Postby ritwik.das » Fri Feb 13, 2009 4:51 pm

Hello Munnu,

Here is a code I developed which will list all "EDI-" variables from a code and write to an output file. After that you may apply DFSORT on the output with SUM FIELDS=NONE option to remove the duplicates. It'd be cumbersome to do with REXX.

P.S - I developed this exec without mainframe and hence could not run it. Please test it before use.

/* REXX */

DROP INREC.                                                           
DROP OUTREC.     
/* HARD-CODE INPUT & OUTPUT FILE */
INFILE  = "XXX.YYY.ZZZ(AAA)"
OUTFILE = "PPP.QQQ.RRR(SSS)"
                                                                     
"ALLOCATE FI(INDSN) DA('"INFILE"') SHR REUSE"                         
"EXECIO * DISKR INDSN (STEM INREC. FINIS"

K = 1
J = 1
POSITION = 0

DO WHILE K <= INREC.0
POSITION = POS("EDI-",INREC.K)
   IF POSITION > 0 THEN DO    
      OUTREC.J = EXTRACTFLD(INREC.K)
      J = J + 1
      SAY "ONE EDI- FIELD FOUND"
   END
   K = K + 1      
END
OUTREC.0 = J - 1
"ALLOCATE FI(OUTDSN) DA('"OUTFILE"') SHR REUSE"                         
"EXECIO * DISKR OUTDSN (STEM OUTREC. FINIS"

/* END MAIN */

EXTRACTFLD:
/* THIS WILL EXTRACT THE VARIABLE NAME FROM THE LINE */
ARG INLINE
DO WHILE SUBSTR(INLINE,POSITION,1) <> " " 
   FLD = FLD || SUBSTR(INLINE,POSITION,1)
   POSITION = POSITION + 1
END   
FLD = STRIP(FLD)
RETURN FLD

/* END EXTRACTFLD */                                                                     
Thanks & Regards!
Ritwik
ritwik.das
 
Posts: 13
Joined: Wed Jul 16, 2008 10:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: REXX code to extract a field from a file

Postby sureshkumar454 » Thu Nov 05, 2009 8:32 pm

Hi,

I am beginner in REXX. I have used the above code to extract a field from a file. I am able to find the string but unable to extract the same to another file. I am gettting the below error while executing the code.
Error running TESTING, line 34: Invalid whole number

I have coded SAY "RC=" RC before RETURN to check the return code. I got RC=0 at that point and after that i am getting the error as mentioned. Please suggest.

Thanks in advance.
sureshkumar454
 
Posts: 5
Joined: Wed Nov 04, 2009 4:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX code to extract a field from a file

Postby MrSpock » Thu Nov 05, 2009 8:43 pm

Please post the TRACE output from your exection of your exec.
User avatar
MrSpock
Global moderator
 
Posts: 807
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post