View previous topic :: View next topic
|
Author |
Message |
tosaurabh20
New User
Joined: 08 Jun 2007 Posts: 26 Location: Noida
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Saurabh,
Welcome back and thank you for posting your solution |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
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 |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
|