IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

String Handling problem.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tosaurabh20

New User


Joined: 08 Jun 2007
Posts: 26
Location: Noida

PostPosted: Thu Jul 26, 2007 5:24 pm
Reply with quote

chintan wrote:
u try for justify right it is synax.......i m not sure but it will solve your problem......


Hi all,

First of all very sorry for not responding, got occupied with project which required this string handling functionality. I will explain the whole scenario and as well as the solution which i implemented.

there is a parm file which is used in program, the contents of which are as follows:

ISELIGIBILITY FAI03U
CD RDS
PUT 'QCPPNP.ADJ.RDSU.ELGP357.A#####.OAUDTRPT' +
RDSUAUDT.XXXXX.A#####.CLIENT_NAME.CCYYMMDDHHMMSS
QUIT

Now my requirement was to replace "XXXXX" with client id from database, now that client can be of any length upto 5 characters.

Also client_name can also be of variable length upto 30 characters, what i need to implement that the whole string should remain in each and every scenario without the extra spaces or special characters.

the solution which i implemented is


UNSTRING INPUT-DATA-CURR
DELIMITED BY '.'
INTO WS-SUBSTRING1 COUNT IN WS-RDSCNT
, WS-SUBSTRING2
, WS-SUBSTRING3
, WS-SUBSTRING4
, WS-SUBSTRING5
END-UNSTRING.


PERFORM VARYING WS-SUB4 FROM +30 BY -1
UNTIL CLT-NM(WS-SUB4:1) NOT = SPACE
END-PERFORM

this will give me a length of the client name.

PERFORM VARYING WS-SUB2 FROM +5 BY -1
UNTIL CLT-CD(WS-SUB2:1) NOT = SPACE
END-PERFORM

this will provide me length of client code.

after that i again concantenated the everything using reference modification.

hope i have made myself clear.

sorry for delay once again.

Thanks for all your suggestions and feedbacks.

Saurabh
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Jul 26, 2007 5:29 pm
Reply with quote

A little hint at the beginning, like you needed to insert the 1 to 5 character string into a 5 character hole and squeeze out the extra spaces would have helped your question along greatly.....
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jul 27, 2007 3:32 am
Reply with quote

Hello Saurabh,

Welcome back and thank you for posting your solution icon_smile.gif
Back to top
View user's profile Send private message
feellikeneo

New User


Joined: 19 Mar 2007
Posts: 73
Location: Chennai

PostPosted: Tue Jul 31, 2007 6:57 pm
Reply with quote

Hi Saurabh,

I too have a similar kind of requirement.

Can you pls, explain what this piece of code will do.

UNSTRING INPUT-DATA-CURR
DELIMITED BY '.'
INTO WS-SUBSTRING1 COUNT IN WS-RDSCNT
, WS-SUBSTRING2
, WS-SUBSTRING3
, WS-SUBSTRING4
, WS-SUBSTRING5
END-UNSTRING.


I too need to remove the trailing spaces and I have to plug the trimmed variable in a JCL. (ie) I will write a JCL from COBOL. I have to plug this trimmed variable.

pls help

Cheers,
Neo icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Aug 01, 2007 5:13 pm
Reply with quote

given the following input:
Code:

<<<<<<input lines 1 thru 3:>>>>>>>>>
ISELIGIBILITY FAI03U
CD RDS
PUT 'QCPPNP.ADJ.RDSU.ELGP357.A#####.OAUDTRPT' +
<<<<<<input line 4:>>>>>>>>>
RDSUAUDT.XXXXX.A#####.CLIENT_NAME.CCYYMMDDHHMMSS
<<<<<<input line 5:>>>>>>>>>
QUIT

each, 80 chars in length and following these requirements:
Quote:

Now my requirement was to replace "XXXXX" with client id from database, now that client can be of any length upto 5 characters.

Also client_name can also be of variable length upto 30 characters, what i need to implement that the whole string should remain in each and every scenario without the extra spaces or special characters.

in the fourth input line you need to replace
  • XXXXX with :CLIENT_ID from database, length 5, spaces on the right to be trimmed
  • CLIENT_NAME in input with :CLIENT_NAME from database, length 30, spaces on the right to be trimmed


Code:

01  WORK-AREAS.
    05  FIRST-PART        PIC X(80).
    05  SECOND-PART       PIC X(80).
    05  THIRD-PART        PIC X(80).
    05  GARBAGE           PIC X(80).
    05  NUM-FIELDS        PIC S9(3).
        88  GOOD-SPLIT     VALUE +3.
    05  RECEIVING-FLD     PIC X(80).

INITIALIZE WORK-AREAS

UNSTRING <input line 4>
               DELIMITED BY 'XXXXX' OR 'CLIENT_NAME'
    INTO FIRST-PART
         SECOND-PART
         THIRD-PART
         GARBAGE
    TALLYING IN NUM-FIELDS
END-UNSTRING

IF GOOD-SPLIT
THEN
    STRING FIRST-PART
                       DELIMITED BY SPACES
           :CLIENT_ID
                      DELIMITED BY SPACES
           SECOND-PART
                      DELIMITED BY SPACES
           :CLIENT_NAME
                      DELIMITED BY SPACES
           THIRD-PART
                      DELIMITED BY SPACES
      INTO RECEIVING-FIELD
   END-STRING

   MOVE RECEIVING-FIELD TO <input-line-4>
ELSE
   DISPLAY 'ERROR'
END-IF
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts file manager is doing string conversion IBM Tools 3
Search our Forums:

Back to Top