Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Convert fixed format record to comma separated format

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
PERUMALA

New User


Joined: 01 Nov 2006
Posts: 9

PostPosted: Wed Nov 01, 2006 4:36 am    Post subject: Convert fixed format record to comma separated format
Reply with quote

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
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Nov 01, 2006 5:27 am    Post subject: Re: convert fixed format record to comma separated format
Reply with quote

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
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Nov 01, 2006 9:07 am    Post subject: Re: convert fixed format record to comma separated format
Reply with quote

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
View user's profile Send private message
PERUMALA

New User


Joined: 01 Nov 2006
Posts: 9

PostPosted: Thu Nov 02, 2006 3:50 am    Post subject: Not worked
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Nov 02, 2006 9:07 am    Post subject: Re: convert fixed format record to comma separated format
Reply with quote

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
View user's profile Send private message
PERUMALA

New User


Joined: 01 Nov 2006
Posts: 9

PostPosted: Thu Nov 02, 2006 8:58 pm    Post subject: Thanks Dick
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Nov 03, 2006 3:32 am    Post subject:
Reply with quote

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 http://ibmmainframes.com//viewtopic.php?t=15129 if you're interested.
Back to top
View user's profile Send private message
karnataka

New User


Joined: 15 Sep 2006
Posts: 20
Location: bangalore

PostPosted: Fri Nov 03, 2006 11:54 am    Post subject:
Reply with quote

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
View user's profile Send private message
abel
Warnings : 1

New User


Joined: 31 May 2006
Posts: 5

PostPosted: Sat Nov 04, 2006 12:55 am    Post subject: Re: convert fixed format record to comma separated format
Reply with quote

hi
can u plz explain it cleary with full program

abel
Back to top
View user's profile Send private message
karnataka

New User


Joined: 15 Sep 2006
Posts: 20
Location: bangalore

PostPosted: Wed Nov 08, 2006 9:32 am    Post subject:
Reply with quote

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
View user's profile Send private message
PERUMALA

New User


Joined: 01 Nov 2006
Posts: 9

PostPosted: Wed Nov 08, 2006 8:18 pm    Post subject: Thanks
Reply with quote

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
View user's profile Send private message
abel
Warnings : 1

New User


Joined: 31 May 2006
Posts: 5

PostPosted: Wed Nov 08, 2006 11:51 pm    Post subject: Re: convert fixed format record to comma separated format
Reply with quote

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
View user's profile Send private message
karnataka

New User


Joined: 15 Sep 2006
Posts: 20
Location: bangalore

PostPosted: Thu Nov 09, 2006 9:50 am    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts How to pick only YYMMDD from DATE1P (... atulbaviskar SYNCSORT 7 Wed Mar 22, 2017 11:39 am
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us