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
 

 

Is there any command in REXX to split a record in to 2 lines

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
bhavya_sha

New User


Joined: 16 Apr 2005
Posts: 33

PostPosted: Mon Feb 15, 2010 10:34 am    Post subject: Is there any command in REXX to split a record in to 2 lines
Reply with quote

Hi,

iam new to rexx and the question iam posing might be very basic kindly excuse.

I got a record which is having non-cobol/english char and when i translate it may not take single byte always and length may go beyond 72.the requirement now is to split the record @ appropriate position if it exceeds 72bytes and move to next line. i've written a logic but it's bit lengthy , kindly let me know if there is any simple procedure to achieve this.

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

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Mon Feb 15, 2010 10:47 am    Post subject: Reply to: Is there any command in REXX to split a record in
Reply with quote

Unless You post Your code, we cannot tell if it is the best choice!
Back to top
View user's profile Send private message
bhavya_sha

New User


Joined: 16 Apr 2005
Posts: 33

PostPosted: Mon Feb 15, 2010 11:48 am    Post subject: Reply to: Is there any command in REXX to split a record in
Reply with quote

CODE IS AS BELOW

Code:
 SPLIT_REC_BYND72:
 PARSE VAR COB_REC.REC_CNT TGTA TGTB
 TGT_DIV = SUBSTR(COB_REC_BYND72.REC_CNT,8,2)                         /* TO CHECK WHETHER THE DATA STARTS FROM COL 8 OR COL12   */
 
 SEQ_NUM = TGTA                                                       /* STORES SEQUENCE NUM PRESENT IN 1-6TH COLUMN           */

 LIN_NO = 1

 /******************************************************************/
 /* IF RECORD CAN FIT IN A SINGLE LINE(72 BYTES) AFTER             */
 /* TRANSLITERATION THEN WRITE TO OUTPUT FILE                      */
 /******************************************************************/

 IF LENGTH(TGTB) <= 60 THEN                       
 DO

   IF TGT_DIV = ' ' THEN
   DO
     CALL LINEOUT COB_SPLT_F,TGTA || ' '|| TGTB
   END
   ELSE
   DO
     CALL LINEOUT COB_SPLT_F,TGTA || '     '|| TGTB
   END
 END

 /******************************************************************/
 /* IF RECORD CANNOT BE ACCOMODATED IN A SINGLE LINE(72BYTES) AFTER*/
 /* TRANSLITERATION THEN SPLIT THE RECORD TO FIT IN                */
 /******************************************************************/

 ELSE IF LENGTH(TGTB) > 60 THEN
 DO
   DO WHILE SPLIT_REC_LEN <= COB_REC_LENGTH
   IF TGT_DIV = '  ' THEN                                             /*IF THE RECORD TO BE SPLITTED STARTS FROM 12TH COLUMN    */
   DO                                                                 /*WRITE TRANSLITERATED TEXT FROM COLUMN12                 */   
     TGTA  = TGTA || '     '
   END
   ELSE
   DO
     TGTA  = TGTA || ' '                                              /*IF THE RECORD TO BE SPLITTED STARTS FROM 8TH COLUMN    */
   END                                                                /*WRITE TRANSLITERATED TEXT FROM COLUMN8                  */
   IF LIN_NO = 1 THEN
    DO
      SPLIT_LEN = 0
      DO WHILE SPLIT_LEN <= 60
         PARSE VAR TGTB TGTC TGTD
     SPLIT_LEN = SPLIT_LEN + LENGTH(TGTC) 
         IF SPLIT_LEN <= 60 THEN
         DO
             TGTA  = TGTA || ' ' || TGTC
             SPLIT_REC_LEN = LENGTH(TGTA)
        TGTB = TGTD
               LIN_NO = LIN_NO + 1
         END

         IF LENGTH(TGTC) > 60 THEN
         DO
           SAY 'LENGTH EXCEEDS 60 BYTES'
         END 
      END
         CALL LINEOUT COB_SPLT_F,TGTA
    SPLIT_REC_LEN = LENGTH(TGTA)
    END
    ELSE
    DO
       SPLIT_LEN = 0
       TGTA = SEQ_NUM ||'     '
       DO WHILE SPLIT_LEN <= 60
         PARSE VAR TGTB TGTC TGTD         
     SPLIT_LEN = SPLIT_LEN + LENGTH(TGTC) 

         IF SPLIT_LEN <= 60 THEN
         DO
             TGTA  = TGTA || ' '|| TGTC
             SPLIT_LEN = LENGTH(TGTA)
        TGTB = TGTD
               LIN_NO = LIN_NO + 1
         END
 
         IF LENGTH(TGTC) > 60 THEN
         DO
           SAY 'LENGTH EXCEEDS 60 COLUMNS'
         END 
       END
        CALL LINEOUT COB_SPLT_F,TGTA 
       SPLIT_REC_LEN = SPLIT_REC_LEN + LENGTH(TGTA)
     END
   END
       OUT_REC = SEQ_NUM || COPIES(' ',(66)) || DATA_73
       CALL LINEOUT COB_SPLT_F , OUT_REC
 END 
 

/************************************************************************************************************************/
Back to top
View user's profile Send private message
sunil kumar purohit

New User


Joined: 10 Sep 2009
Posts: 37
Location: bangalore

PostPosted: Mon Feb 15, 2010 6:39 pm    Post subject: Reply to: Is there any command in REXX to split a record in
Reply with quote

Hi Bhavya,
I think SubStr function may help you.
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Mon Feb 15, 2010 10:03 pm    Post subject:
Reply with quote

Parse is a good technique. alternatively, you an use the word() or subword() functions to break apart records, creating new records as you go, checking the length before adding another word, as it appears you are already doing. Parse is pretty fast though. If it works, what I understand you to have here looks good (I didn't try it).
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
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fail to change physical VSAM filename... jacobdng CICS 7 Fri Jan 20, 2017 12:36 pm
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am


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