View previous topic :: View next topic
|
Author |
Message |
b4uthammi Warnings : 2 New User
Joined: 21 Feb 2005 Posts: 14 Location: hyderabad
|
|
|
|
Hai ,
Please give me the solution for below logic.
i have input file record structure like this
05 EMPLOYEE-NAME.
10 FIRST-NAME PIC X(12).
10 MIDDLE-INIT PIC X.
10 LAST-NAME PIC X(17).
i want to concatinate like last-name,middle-init,last-name
but the problem is my input for LAST-NAME is varying from 4 to 17 like
"james "
"john j cranley "
"J M LOGAN INC "
sample output records:
last-name,middle-init,last-name
"JOHN J CRANLEY CO,,"
"MUTSCHELLER,JAMES,F"
"SOO,ROGER,"
TR |
|
Back to top |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
Hi TR,
Must be a training question 'cause an identical one was posted and solved right here. Just do some searching in the forum and very often the solution is there. |
|
Back to top |
|
|
b4uthammi Warnings : 2 New User
Joined: 21 Feb 2005 Posts: 14 Location: hyderabad
|
|
|
|
Hi Bitneuker,
Thanks for your early response.The posted query is not a training one.it is the one which i need to implement in one of my program(project).
yes, i have gone through the solution which is in the forum,but mine is different .
in the out put record i need to place ',' explicitly after every field.
Sample input data:
05 EMPLOYEE-NAME.
10 FIRST-NAME PIC X(12) VALUE 'JAME'
10 MIDDLE-INIT PIC X VALUE 'D'.
10 LAST-NAME PIC X(17) VALUE 'W A U & ASSOCIATE' .
expected output::
"W A U & ASSOCIATE,JAME,D"
THANKS,
TR |
|
Back to top |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
Have some reading about the string statement over here. The manual is at the forum (topline -> manuals) |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
b4uthammi wrote: |
yes, i have gone through the solution which is in the forum,but mine is different . |
I disagree, the solutions provided do exactly what you want.
Quote: |
in the out put record i need to place ',' explicitly after every field.
|
With a very minor modification..... |
|
Back to top |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
Quote: |
With a very minor modification..... |
and following the link I posted before you may find out how......... |
|
Back to top |
|
|
vijayamadhuri
Active User
Joined: 06 Apr 2005 Posts: 180
|
|
|
|
You would have to code it as
STRING WS-first-name WS-mid-name WS-last-name
DELIMITED BY SIZE
INTO EMPLOYEE-NAME
Irrespective of the length of u r last name this will work.
If you want to put comma then
just define another structure of EMPLOYEE-NAME
as EMPLOYEE-NAME1
05 EMPLOYEE-NAME1.
10 FIRST-NAME PIC X(12).
10 ws-comma pic x(1) value ','.
10 MIDDLE-INIT PIC X.
10 ws-comma pic x(1) value ','.
10 LAST-NAME PIC X(17). EMPLOYEE-NAME1.
Move employee-name fields to employee-name1 fields and then use STRING. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
vijayamadhuri wrote: |
DELIMITED BY SIZE |
Except that will not get the desired results
Quote: |
DELIMITED BY phrase
The DELIMITED BY phrase sets the limits of the string.
.
.
SIZE Transfers the complete sending area. |
|
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
TR,
The problem comes in determining the length of the significant characters in the string. This is where the ?INSPECT? and ?FUNCTION REVERSE? come in. Once you have the lengths of the individual strings then it?s pretty straight forward with ?STRING? or as priyesh.agrawal did with reference modification moves.
Take a look again at the post priyesh.agrawal made. The link is posted by Bitneuker Tue Jan 02, 2007 5:08 pm |
|
Back to top |
|
|
b4uthammi Warnings : 2 New User
Joined: 21 Feb 2005 Posts: 14 Location: hyderabad
|
|
|
|
Hi David,
It is working fine except for ','.
My requirement is after every string i want ','.
output::
last-name first-name middle-init
BEARDEN WARREN H
expected ouput:
BEARDEN,WARREN,H
Thanks in advance
TR |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hi b4uthammi
Your problem is already solved.MOVE ',' TO wherever you need
Thanks'
Arun |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
b4uthammi wrote: |
It is working fine except for ','.
My requirement is after every string i want ','.
output::
last-name first-name middle-init
BEARDEN WARREN H
expected ouput:
BEARDEN,WARREN,H |
Just for fun, post (using CODE) your code, I'll bet we can make it work exactly as you want it to. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hi
You can try STRING also
Code: |
WORKING-STORAGE SECTION.
77 FIR PIC X(20).
77 MID PIC X(20).
77 LAS PIC X(20).
77 RESULT PIC X(60).
77 FIR-LEN PIC 99 VALUE 0.
77 MID-LEN PIC 99 VALUE 0.
77 LAS-LEN PIC 99 VALUE 0.
PROCEDURE DIVISION.
INSPECT FIR TALLYING FIR-LEN FOR CHARACTERS BEFORE ' '
INSPECT MID TALLYING MID-LEN FOR CHARACTERS BEFORE ' '
INSPECT LAS TALLYING LAS-LEN FOR CHARACTERS BEFORE ' '
STRING FIR(1 : FIR-LEN) ','
MID(1 : MID-LEN) ','
LAS(1 : LAS-LEN) DELIMITED BY SIZE
INTO RESULT
DISPLAY RESULT
STOP RUN.
|
Thanks
Arun |
|
Back to top |
|
|
b4uthammi Warnings : 2 New User
Joined: 21 Feb 2005 Posts: 14 Location: hyderabad
|
|
|
|
Hai all,
My problem got resolved.now it is working fine with agarwal logic after few modifications.
Thanks
TR |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
b4uthammi wrote: |
My problem got resolved.now it is working fine with agarwal logic after few modifications. |
We've had so much fun trying to help, why don't you post your solution for all to enjoy? |
|
Back to top |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
William Thompson wrote: |
b4uthammi wrote: |
My problem got resolved.now it is working fine with agarwal logic after few modifications. |
We've had so much fun trying to help, why don't you post your solution for all to enjoy? |
Yes please........... |
|
Back to top |
|
|
prav_06 Warnings : 1 Active User
Joined: 13 Dec 2005 Posts: 154 Location: The Netherlands
|
|
|
|
Concat Strings ... Here is a simple way to do it check out the below pgm
ID DIVISION.
PROGRAM-ID. PRAV.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INREC.
05 WS-VAR1 PIC X(4) VALUE 'KING'.
05 WS-VAR2 PIC X(2) VALUE 'K'.
05 WS-VAR3 PIC X(9) VALUE 'MARSHALL'.
PROCEDURE DIVISION.
PARA1.
DISPLAY WS-VAR1 ',' WS-VAR2 ',' WS-VAR3.
STOP RUN.
output would be
KING,K,MARSHALL |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Quote: |
01 INREC.
05 WS-VAR1 PIC X(4) VALUE 'KING'.
05 WS-VAR2 PIC X(2) VALUE 'K'.
05 WS-VAR3 PIC X(9) VALUE 'MARSHALL'.
|
prav_06,
the problem was not so much how to string the variables together, as much as how to sting just the significant characters together.
If your input record were to read
Quote: |
01 INREC.
05 WS-VAR1 PIC X(8) VALUE 'KING'.
05 WS-VAR2 PIC X(5) VALUE 'K'.
05 WS-VAR3 PIC X(10) VALUE 'MARSHALL'.
|
you display would yeald
Code: |
'KING ,K ,MARSHALL '
|
and what was wanted was like your original display
|
|
Back to top |
|
|
prav_06 Warnings : 1 Active User
Joined: 13 Dec 2005 Posts: 154 Location: The Netherlands
|
|
|
|
Hi David ,
I had tried running the pgm in my Mainframe machine it yeilded me an output
and not like
Quote: |
'KING ,K ,MARSHALL |
' , in the previous post i had just copied my output of my spool display. Kindly check the code.
Thanx,
Thamilzan. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hi Thamilzan
The problem was not just to display it in a particular way.It was to concatenate three variables(that might be having trailing spaces or spaces in between) into a single one and i think he has already got the solution.
Quote: |
Hi David ,
I had tried running the pgm in my Mainframe machine it yeilded me an output Quote:
King,K,Marshall
|
How the trailing spaces got checked off by your mainframe machine!!!
Thanks
Arun |
|
Back to top |
|
|
|