Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
MOVE full string into a receiving field in loop

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

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Thu Jul 31, 2008 3:33 pm    Post subject: MOVE full string into a receiving field in loop
Reply with quote

i am facing problem with string concept in cobol.
my requirement is like this,THIS CONCEPT I AM USING FOR DYNEMEIC SQL PROCESSING.

Code:
05  WS-VAR1                  PIC X(02) VALUE 1.
05   WS-UNION                PIC X(05) VALUE 'UNION'.
05  WS-SELECT                PIC X(20) VALUE SPACES.
05  WS-SELECT                PIC X(20) VALUE SPACES.         
05  WS-DYN-SELECT.                                           
      49  WS-DS-LENGTH       PIC S9(04)   VALUE +4000  COMP. 
      49  WS-DS-COMMAND      PIC  X(4000) VALUE SPACES.       
05  WS-DYN-WHERE.                                             
      49  WS-WHERE-LEN       PIC S9(04)   VALUE +4000  COMP. 
      49  WS-WHERE-COMMAND   PIC  X(4000) VALUE SPACES.       
05  WS-DYN-OPEN.                                             
      49  WS-OPEN-LEN        PIC S9(04)   VALUE +4000  COMP. 
      49  WS-DYNCURSOR-OPEN  PIC  X(4000) VALUE SPACES.       


STRING ' WHERE SEND_RT_NO = ? ',               
       ' AND   RECV_RT_NO = ? ',               
       ' AND   RESEND_IND = ? ',               
       ' AND   FILE_RECV_CNT = ? ',           
       ' AND   CREA_DTE = ? ',                 
       ' AND   CREA_TME = ? ',                 
       ' AND   CASH_LET_BUS_DTE = ? ',         
       ' AND   CASH_LET_ID = ? ',             
       ' AND   BUNDLE_ID = ? ',               
       ' AND   CNTL_REC_IND = ?> '             
       DELIMITED BY SIZE                       
       INTO WS-WHERE-COMMAND                   
END-STRING

STRING  LK-DBL-SEND-ABA1,         
        LK-DBL-RECV-ABA1,         
        LK-DBL-RESEND-IND,       
        LK-DBL-FILE-RECV-IND1,   
        LK-DBL-CREATE-DATE,       
        LK-DBL-CREATE-TIME,       
        LK-DBL-BUSINESS-DATE,     
        LK-DBL-CASH-LET-ID,       
        LK-DBL-BUNDLE-ID,         
        LK-DBL-HEADER             
        DELIMITED BY SIZE         
        INTO WS-DYNCURSOR-OPEN   
END-STRING                       
                                   
STRING '<SELECT * FROM ARW0.' 
DELIMITED BY SIZE             
INTO WS-SELECT.               

PERFORM UNTIL WS-VAR1 = WS-SUB1                             
        ADD 1 TO LK-SUB1                                     
        MOVE LK-CNTL-TBNAME1(LK-SUB1)   TO                   
                                  WS-CNTL-TBNAME1(WS-VAR1)   
        MOVE WS-CNTL-TBNAME1(WS-VAR1) TO WS-TBNAME1         
        MOVE WS-TBNAME1(1:11)         TO WS-TBNAME           
        IF WS-VAR1 = 1                                       
            STRING WS-SELECT DELIMITED BY SIZE               
                   WS-TBNAME                                 
                   WS-WHERE-COMMAND DELIMITED BY SIZE       
                   INTO WS-DS-COMMAND                       
        END-IF
   IF WS-VAR1 > 1                               
       STRING WS-DS-COMMAND DELIMITED BY SIZE   
           WS-SELECT DELIMITED BY SIZE       
           WS-TBNAME                         
           WS-WHERE-COMMAND DELIMITED BY SIZE
           INTO WS-DS-COMMAND                 
   END-IF
******************************************************************     
**** HERE THE UNION KEYWORD IS ADD END OF EACH SELECTMENT.IF THE       
**** BELOW CONDITION SATISFIES THEN IT WON'T BE ADD IN THE SELECT.     
******************************************************************     
       IF WS-VAR1 NOT = WS-SUB1                                         
          STRING WS-DS-COMMAND DELIMITED BY SIZE                       
                 WS-UNION      DELIMITED BY SIZE                       
                 INTO WS-DS-COMMAND                                     
       END-IF                                                           
       ADD 1 TO WS-VAR1                                                 
       END-PERFORM.                                                     
          DISPLAY WS-DS-COMMAND.                                       


I WANT OUT PUT LIKE THIS.

Code:
<SELECT * FROM ARW0.ARWX9-T008 WHERE ACNO = ? AND NAME = ?> UNION <SELECT * FROM ARW0.ARWX9-T009 WHERE ACNO = ? AND NAME = ?> UNION <SELECT * FROM ARW0.ARWX9-T010 WHERE ACNO = ? AND NAME = ?>

BUT I AM GETTING THE STRING EVEN PUT IN A LOOP LIKE THIS(I DISPLAYED WS-DS-COMMAND),

Code:
<SELECT * FROM ARW0.ARWX9-T008 WHERE ACNO = ? AND NAME = ?>
Back to top
View user's profile Send private message

babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Thu Jul 31, 2008 7:40 pm    Post subject:
Reply with quote

please give any idea for my problem in string?
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 Jul 31, 2008 7:52 pm    Post subject:
Reply with quote

Hello,

Add some DISPLAY statements after the various STRINGs to see what is happening. You would want to identify each different DISPLAY so you know which part of the code you are in and i'd suggest displaying the subscripts as well.

Code:
05  WS-VAR1                  PIC X(02) VALUE 1.
Why is this field defined as X(2)?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Jul 31, 2008 7:52 pm    Post subject:
Reply with quote

you delimit each ws-xx-command with size. each is in a 4000 char area, yet you string to only 4000. you have a 4000 bag with 8000 lbs of ....
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Jul 31, 2008 7:54 pm    Post subject:
Reply with quote

i would initialize the ws-nn-commands with high values. then when the ws-nn.command field is moved delimit based on high-values not size. that will get you thru a couple.

you need to keep track of your lengths (actual area populated).
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 757
Location: Germany

PostPosted: Thu Jul 31, 2008 9:54 pm    Post subject:
Reply with quote

I would use several dedicated areas. Also i would follow the advice of dbzTHEdinosauer, initialize this areas initialized by high values.

Then I would build a logic, using STRING and UNSTRING with the POINTER options.
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 line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us