View previous topic :: View next topic
|
Author |
Message |
adarsh444
New User
Joined: 02 Nov 2006 Posts: 17
|
|
|
|
Hi everyone,
I have fields
01 ws-name pic x(15)
01 ws-date pic x(10)
I am using
STRING 'ACCOUNT NAME:' DELIMITED BY SIZE
WS-NAME DELIMITED BY SPACE
WS-DATE DELIMITED BY SIZE INTO WS-DISPLAY
and output is displayed as
ACCOUNT NAME: MMISCHELLE/20040506
As per the reqirement should be displayed as
ACCOUNT NAME: M MISCHLLE/20040506
Can anyone help me in formatting this.
Waiting for reply.
Thank you |
|
Back to top |
|
|
sankar_MF
New User
Joined: 19 Sep 2006 Posts: 29
|
|
|
|
Hi,
Please use the string command as follows, you will get the required output.
STRING 'ACCOUNT NAME:'DELIMITED BY SIZE
WS-NAME(1:1) ' ' DELIMITED BY SIZE
WS-NAME(2:14) DELIMITED BY SPACE
WS-DATE DELIMITED BY SIZE INTO WS-DISPLAY
Thanks
Sankar |
|
Back to top |
|
|
adarsh444
New User
Joined: 02 Nov 2006 Posts: 17
|
|
|
|
Hi
But that will work only for the sample data i have given.
ACCOUNT NAME: M MISCHLLE/20040506
I have lots of names(WS-NAME) embedded with spaces in between.
I want to handle all the cases. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Please give more examples of WS-NAME |
|
Back to top |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
Considering M and MISCHLLE as first name and last name, I think this code will work
Code: |
ID DIVISION.
PROGRAM-ID. SAMP.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NAME PIC X(15).
01 WS-DATE PIC X(10).
01 WS-FNAME PIC X(15).
01 WS-LNAME PIC X(15).
01 WS-DISPLAY PIC X(60).
PROCEDURE DIVISION.
MAIN.
MOVE 'ALEX THOMAS' TO WS-NAME.
MOVE '20040506' TO WS-DATE.
UNSTRING WS-NAME DELIMITED BY ' ' INTO WS-FNAME WS-LNAME.
STRING 'ACCOUNT NAME : ' DELIMITED BY SIZE WS-FNAME
DELIMITED BY SPACE ' ' DELIMITED BY SIZE WS-LNAME DELIMITED
BY SPACE '/' DELIMITED BY SIZE WS-DATE DELIMITED BY SIZE
INTO WS-DISPLAY.
DISPLAY WS-DISPLAY.
STOP RUN. |
will give result as
Code: |
ACCOUNT NAME : ALEX THOMAS/20040506 |
|
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hi Adarsh,
Try this code.
Code: |
WORKING-STORAGE SECTION.
77 NAME-IN PIC X(15) VALUE 'ARUN RAJ S'.
77 DATE-IN PIC X(10) VALUE '20061201'.
77 RES PIC X(25).
PROCEDURE DIVISION.
MAIN.
STRING NAME-IN DELIMITED BY ' ' ------>DOUBLE SPACE
'/' DELIMITED BY SIZE
DATE-IN DELIMITED BY SIZE INTO RES
DISPLAY '(' RES ')'
STOP RUN.
|
Please let me know if it is working as per your requirement.
Thanks
Arun |
|
Back to top |
|
|
|