View previous topic :: View next topic
|
Author |
Message |
PERUMALA
New User
Joined: 01 Nov 2006 Posts: 9
|
|
|
|
Hi,
I have an input file having records in the format
Code: |
F1 : PIC X(4)
F2 : PIC X(1) VALUE ","
F3 : PIC X(10)
F4 : PIC X(1) VALUE ","
F5 : PIC ++++++++++.99
F6 : X(1) VALUE "," |
The sample of the record in the input file is
Code: |
(RD),A0101bbbbbb,bbb+43173.37,
(RD),A0101BBOAE,bb+299740.96, |
b represents space in the above input record
The out put of the reocrd should look like
Code: |
(RD),A0101B,+43173.37, ( The spaces are removed)
(RD),A0101BBOAE,+299740.96, |
Is it possible to get this result using COBOL If yes Please let me know how can be done?
Thanks
Venkata Perumala |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Vankata,
You may want to go thru RULES of the forum... Pls do not repost the same question in multiplt sections.
I got deleted the other.
Coming to ur question. Just before writing the records...
1> Reverse F3 giving REV-F3.
2> Inspect for the leading spaces tallying CNTR on REV-F3.
3> Write F3(1:L-CNTR)
Let me know if u dont know converting it in code. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Okie... I did n't notice you have another F5 to make up...
Try this if it works for you...
Code: |
01 WS-COMB.
05 WS-F1 PIC X(04).
05 WS-F2 PIC X(01).
05 WS-COMB PIC X(24).
05 WS-F6 PIC X(01).
MOVE F1 TO WS-F1.
MOVE F2 TO WS-F2.
MOVE F3 TO WS-COMB(1:10).
MOVE F4 TO WS-COMB(11:1).
MOVE F5 TO WS-COMB(12:13).
MOVE F6 TO WS-F6.
UNSTRING WS-COMB DELIMITED BY ' ' INTO WS-FIN-F3, WS-FIN-F4, WS-FIN-F5.
STRING WS-F1 DELIMITED BY SIZE
WS-F2 DELIMITED BY SIZE
WS-FIN-F3 DELIMITED BY SIZE
WS-FIN-F4 DELIMITED BY SIZE
WS-FIN-F5 DELIMITED BY SIZE
WS-F6 DELIMITED BY SIZE
INTO WS-OUT.
WRITE WS-OUT. |
|
|
Back to top |
|
|
PERUMALA
New User
Joined: 01 Nov 2006 Posts: 9
|
|
|
|
Hi Priyesh,
This has not worked as again WS-FIN-F3,WS-FIN-F4,WS-FIN-F5, are again containing the blank spaces
Thanks for your reply
Venkata Perumala |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Assuming F3 is fixed, even though your sample input records had different sized F3's:
Code: |
F1 : PIC X(4)
F2 : PIC X(1) VALUE ","
F3 : PIC X(10)
F4 : PIC X(1) VALUE ","
F5 : PIC ++++++++++.99
F6 : X(1) VALUE ","
WK-1 PIC X(13).
88 NICHTS VALUE SPACES.
WK-2 PIC X(13).
88 NICHTS VALUE SPACES.
LEFT-JUST PIC X(13).
OUTPUT-REC-WORK PIC X(27). *MAX LEN F1 F3 F5
<input into AREA containing F1,F2,F3,F4,F5,F6>
SET NICHTS IN WK-1
NICHTS IN WK-2 TO TRUE
UNSTRING F5 DELIMITED BY ALL SPACES INTO WK-1 WK-2
IF NICHTS IN WK-1
THEN
MOVE WK-2 TO LEFT-JUST
ELSE
MOVE WK-1 TO LEFT-JUST
END-IF
STRING F1 DELIMITED BY SIZE
F3 DELIMITED BY SPACE
LEFT-JUST DELIMITED BY SPACE
INTO OUTPUT-REC-WORK |
|
|
Back to top |
|
|
PERUMALA
New User
Joined: 01 Nov 2006 Posts: 9
|
|
|
|
Hi Dick,
The logic worked fine.
Except it just gave compilation error while doing unstring F2 as it was numeric edited.I moved F5 to some alphanumeric field and did unstring.
It worked good.
Thanks a lot for your help
Venkata Perumla |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
For the record, Venkata asked this same question in the DFSORT Forum and I showed him how to do what he wanted with a couple of simple DFSORT control statements (but it requires a DFSORT PTF from April, 2006 that he doesn't have yet).
See ibmmainframes.com//viewtopic.php?t=15129 if you're interested. |
|
Back to top |
|
|
karnataka
New User
Joined: 15 Sep 2006 Posts: 20 Location: bangalore
|
|
|
|
hi,
this is one more logic to eliminate space. check it out
Code: |
WORKING-STORAGE SECTION.
01 INPUT-DATA.
02 F1 PIC X(4).
02 F2 PIC X(1) VALUE ",".
02 F3 PIC X(10).
02 F4 PIC X(1) VALUE ",".
02 F5 PIC ++++++++++.99.
02 F6 PIC X(1) VALUE ",".
01 OUTPUT-DATA PIC X(30).
01 J PIC 99 VALUE 01.
01 I PIC 99 VALUE 01.
PROCEDURE DIVISION.
000-MAIN-PARA.
ACCEPT INPUT-DATA.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 29
IF INPUT-DATA(I:1) NOT EQUAL SPACE
MOVE INPUT-DATA(I:1) TO OUTPUT-DATA(J:1)
ADD 1 TO J
END-IF |
here output-data is having data in reqiured formate.
input-data:
Code: |
(RD),A0101bbbbbb,bbb+43173.37,
(RD),A0101BBOAE,bb+299740.96, |
output-data:
Code: |
(RD),A0101B,+43173.37, ( The spaces are removed)
(RD),A0101BBOAE,+299740.96, |
plz let me know if its wrong
thanks.... |
|
Back to top |
|
|
abel Warnings : 1 New User
Joined: 31 May 2006 Posts: 5
|
|
|
|
hi
can u plz explain it cleary with full program
abel |
|
Back to top |
|
|
karnataka
New User
Joined: 15 Sep 2006 Posts: 20 Location: bangalore
|
|
|
|
hi,
here i am not using any input files .plz take care to modify this logic using input files according to your requirement.
IDENTIFICATION DIVISION.
PROGRAM-ID. EVEL.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INPUT-DATA.
02 F1 PIC X(4).
02 F2 PIC X(1) VALUE ",".
02 F3 PIC X(10).
02 F4 PIC X(1) VALUE ",".
02 F5 PIC ++++++++++.99.
02 F6 PIC X(1) VALUE ",".
01 OUTPUT-DATA PIC X(30).
01 J PIC 99 VALUE 01.
01 I PIC 99 VALUE 01.
PROCEDURE DIVISION.
000-MAIN-PARA.
ACCEPT INPUT-DATA.
HERE PERFROM STATEMENT IS ELIMINATING EMBEDDED SPACE IN A STRING
INPUT==> INPUT-DATA(LENGTH OF 29 CHARECTER)
(RD),A0101BBBBB,BBBB+4317337
OUTPUT==> OUTPUT-DATA(LENGTH OF 29 CHARECTER)
(RD),A0101,+4317337
IT IS CHECKING EACH AND ALL CHARECTER OF INPUT-DATA.IF IT ENCOUNTERS
ANY CHARECTER EXCEPT BLANKSPACE THEN ONLY THAT CHARECTER WILL BE MOVED
TO OUTPUT-DATA. SO OUTPUT-DATA IS NOT HAVING ANY EMBEDDED SPACE.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 29
IF INPUT-DATA(I:1) NOT EQUAL SPACE
MOVE INPUT-DATA(I:1) TO OUTPUT-DATA(J:1)
ADD 1 TO J
END-IF
END-PERFORM.
DISPLAY 'INPUT-DATA==>' INPUT-DATA.
DISPLAY 'OUTPUT-DATA==>' OUTPUT-DATA.
STOP RUN.
if its not meeting your requirement or having any douts plz let me know.
thanks |
|
Back to top |
|
|
PERUMALA
New User
Joined: 01 Nov 2006 Posts: 9
|
|
|
|
Hi,
Thanks a lot for your efforts. I alerady updated in my earlier post
Thu Nov 02, 2006 8:28 pm saying my problem got resolved.
Yes this logic also looks good.
Thanks
Venkata Perumala |
|
Back to top |
|
|
abel Warnings : 1 New User
Joined: 31 May 2006 Posts: 5
|
|
|
|
Thanks for your reply but the problem is
INPUT-DATA(I:1)
That I:1 is not working can you please give me more details about it and also an substitute for it.
abel |
|
Back to top |
|
|
karnataka
New User
Joined: 15 Sep 2006 Posts: 20 Location: bangalore
|
|
|
|
hi abel
i have executed this code this is working fine here. can u send me what error mes your r getting so that i could help you little bit.
here is the explanation for INPUT-DATA(I:1):
INPUT-DATA(I:B) ==> HERE I INDICATES POSSITION OF A SUBSTRING WITH IN
INPUT-DATA AND B INDICATE LENGTH OF SUBSTRING FROM POSSITION I.
EX: INPUT-DATA IS HAVING 'IBM LTD' AND IF I=2 AND B=1
INPUT-DATA(I:1) = INPUT-DATA(2:1) INDICATES FROM SECOND POSSITION TILL LENGTH of 1 CHARECTER i.e, 'B'.
THERE FORE 'MOVE INPUT-DATA(I:1) TO ABC' WILL MOVE 'B' TO ABC
having any douts plz let me know
thanks, |
|
Back to top |
|
|
|