View previous topic :: View next topic |
Author |
Message |
Siddheart22 Beginner

Joined: 11 Apr 2005 Posts: 42 Topics: 19 Location: India
|
Posted: Mon Oct 03, 2005 9:07 pm Post subject: Variable Data |
|
|
Hi,
I have a DB2 unload file which contains a field [besides many others] - NAME-FIELD 100 bytes long.
This field could contain First Name, Last Name, or both. There could be one or more space/s between the first & last names.
E.g. of NAME-FIELD Content:
MR. JOHN HUNKINS
MRS. JEAN LIVINGSTON
MR. LEON B.
MR. YURI SHTEMBERG
MRS. BRIGITTE S.
My question is:
If I want to read every record and move only the data part of the NAME-FIELD excluding the trailing spaces after the last name, which is the most efficient way of doing it?
Thanks in advance,
Siddheart22. |
|
Back to top |
|
 |
ANIL SARATHY Beginner

Joined: 30 Aug 2005 Posts: 88 Topics: 3 Location: Syracuse,New york
|
Posted: Tue Oct 04, 2005 12:09 am Post subject: |
|
|
Read the variable from right until you read first space character.
01 WS-NAME-CHK PIC X(30).
01 WS-END-OF-FIELD pic x(1)
88 END-FOUND value 'Y'
PERFORM VARYING WS-SUB-NAME FROM
30 BY -1
UNTIL END-FOUND OR WS-SUB-NAME = 0
IF WS-NAME-CHK(WS-SUB-NAME:1) NOT EQUAL TO SPACE
MOVE 'Y' TO WS-END-OF-FIELD
DISPLAY 'LENGTH ' WS-SUB-NAME
END-IF
END-PERFORM
use WS-NAME-CHK(1:WS-SUB-NAME) to move into a variable. _________________ Anil Sarathy |
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
|
|