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
 

 

Include afer IFTHEN in DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Wed Oct 10, 2007 12:19 am    Post subject: Include afer IFTHEN in DFSORT
Reply with quote

This code is correct but how to eliminate records which doesn't contain the string 'MOVE' after IFTHEN (INCLUDE is not allowed) ?

Code:

 //S1    EXEC  PGM=ICEMAN
 //SYSOUT    DD  SYSOUT=*
 //SORTIN DD DSN=ETUD.L255428.ARS04.PGM(ARHI100E),DISP=SHR
 //SORTOUT DD DSN=ETUD.L255428.BGQA050E.MOVE,
 //             DISP=(MOD,CATLG),
 //             UNIT=DISK,
 //             SPACE=(CYL,(1,1),RLSE)
 //SYSIN    DD    *
   OPTION COPY
   OMIT  COND=(7,1,CH,EQ,C'*')
   INREC IFOUTLEN=80,
    IFTHEN=(WHEN=(7,1,CH,NE,C'*'),
        PARSE=(%00=(STARTAT=C' MOVE ',FIXLEN=6),
          %01=(STARTAT=NONBLANK,ENDBEFR=C' TO ',FIXLEN=31),
          %02=(STARTAT=NONBLANK,FIXLEN=31)),
        BUILD=(%00,%01,C' TO ',%02,80:X))


e.g I want to omit the first record
Code:

                                     TO
MOVE 'SPI3TAB'                       TO WSPI-FICNAME.
MOVE SPACE                           TO WSPI-PARAMETRE.
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: Wed Oct 10, 2007 1:09 am    Post subject:
Reply with quote

Use OUTFIL OMIT=(...) or OUTFIL INCLUDE=(...). OUTFIL is processed after INREC.

If that doesn't answer your question, then please explain in more detail what you're trying to do with an example of the input records and the expected output.
Back to top
View user's profile Send private message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Wed Oct 10, 2007 4:11 pm    Post subject:
Reply with quote

Thank you, it exactly answers my question. But I realized it's more complicated. In fact I want to extract all lines containing "MOVE A TO B" in a COBOL PGM. Unfortunatly, some MOVE are on 2 lines and may be not subsequent

See the example below :
Code:

            MOVE     AAA     TO  BBBB
            MOVE     CCCC     TO  DDDDDDDDDD
            MOVE     EEEEEEE          TO
                                           FFFFFFF
            MOVE     GGGGGGGG         
                                         TO   HHHHHH

            MOVE     IIIIIIIII         
      *             
                                         TO   JJJJJJ



And I want, after PARSE :
Code:

MOVE AAA                    TO BBBB
MOVE CCCC                   TO DDDDDDDDDD
MOVE EEEEEEE                TO FFFFFFF
MOVE GGGGGGGG               TO HHHHHH         
MOVE IIIIIIIII              TO JJJJJJ


So, how to make the link between n lines performing the same MOVE ?
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: Wed Oct 10, 2007 9:45 pm    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG   DD  SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN   DD    *
COPY FROM(IN) TO(T1) USING(CTL1)
SPLICE FROM(T1) TO(OUT) ON(81,8,ZD) KEEPNODUPS -
  WITH(40,31) USING(CTL2)
/*
//CTL1CNTL DD *
  OMIT COND=(7,1,CH,EQ,C'*',OR,1,50,CH,EQ,C' ')
  INREC IFTHEN=(WHEN=(1,20,SS,EQ,C'MOVE'),
         PARSE=(%=(STARTAFT=C'MOVE '),
          %01=(STARTAT=NONBLANK,ENDBEFR=C' TO ',FIXLEN=31),
          %02=(STARTAT=NONBLANK,FIXLEN=31)),
         BUILD=(1:C'MOVE',6:%01,37:C'TO',40:%02)),
        IFTHEN=(WHEN=(1,60,SS,EQ,C' TO '),
         PARSE=(%=(STARTAFT=C' TO '),
          %03=(STARTAT=NONBLANK,FIXLEN=31)),
         OVERLAY=(40:%03)),
        IFTHEN=(WHEN=NONE,
         PARSE=(%04=(STARTAT=NONBLANK,FIXLEN=31)),
         OVERLAY=(40:%04))
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,4,CH,EQ,C'MOVE'),
                OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(89:SEQNUM,8,ZD,
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=OUT,BUILD=(1,80)
/*
Back to top
View user's profile Send private message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Thu Oct 11, 2007 12:45 am    Post subject:
Reply with quote

Thank you, it realizes exactly what I wanted in my example... but with a real COBOL program I've got some problem :

Result:
Code:

********************************* Top of Data ***************
       IDENTIFICATION      DIVISION.   IF FIN-FIC-CALEND
MOVE SPACE                          TO IF FIN-FIC-ENTREE
MOVE SPACE                          TO IF FIN-FIC-DOSS
MOVE SPACE                          TO WS-CPT (05)
..........

MOVE RCB-DOSS-AFF-MAIT-NO-2         TO S-V14040-DOSS-AFF-MAIT-NO-2
MOVE RCB-DOSS-AFF-MAIT-CDT-2        TO CMEN      IF RCB-ENG-DTDEB = ZE
MOVE WS-DATE-DB2-INIT               TO ELSE
MOVE RCB-ENG-DTDEB                  TO CMEN      IF RCB-ENG-DTFIN = ZE
MOVE WS-DATE-DB2-INIT               TO ELSE



I Join the file containing the PGM
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: Thu Oct 11, 2007 1:40 am    Post subject:
Reply with quote

I gave you what you asked for. Now you're asking for a lot more.

I assumed from what you told me that you only had comment statements, blank statements, MOVE statements and at most one continuation line for a MOVE statement. But you appear to have all manner of statements beyond those. You would have to omit all but the type of lines you showed me originally for this to work.

Changing the OMIT statement to:

Code:

  OMIT COND=(7,1,CH,EQ,C'*',OR,1,50,CH,EQ,C' ',OR,   
   1,20,SS,NE,C'MOVE ')                             


will get you the correct output when the entire MOVE a TO b statement is on the same line. But it won't get you the MOVE statements split across lines. There's nothing special about the lines following the MOVE lines that would allow us to extract them without extracting other lines. If the continuation lines all had TO b we could do it, but they don't. There also seem to be instances of multiple continuation lines after a MOVE line. I don't know if you want to do something with those lines or not, but if you do that makes it even more complicated.

Maybe some method with grouping and SPLICE would do what you want, but I don't understand what you want sufficiently to say for sure.
Back to top
View user's profile Send private message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Thu Oct 11, 2007 3:54 am    Post subject:
Reply with quote

I realize it's more complex than I thought. For example, I can see in the program to analyse such sequence like
Code:

               MOVE WS-DATE-DB2-INIT     TO S-V14040-DOSS-DOUV
                                            S-V14040-DOSS-DCLOT
                                            S-V14040-DOSS-DMODIF
                                            S-V14040-DOSS-DPURGE
                                            S-V14040-DOSS-DIV-DDEB
                                            S-V14040-DOSS-DIV-DFIN


And we have to recognize what follows the "TO", e.g.
in
Code:

          MOVE   A TO B C PERFORM P


The result should be
Code:

  MOVE A                  TO B
  MOVE A                  TO C


instead of
Code:

  MOVE A                  TO B
  MOVE A                  TO C
  MOVE A                  TO PERFORM
  MOVE A                  TO P


The rule could be something like that :
check only lines whose column 7 doesn't contain '*' and after column 12 :
1- identify the statement ' MOVE '
2- extract word(s) before ' TO ', may be in next line(s) (even for ' TO ')
3- extract word(s) after ' TO ' and stop when a special words is found as statements PEFORM, MOVE, IF, CALL... (beginning of new statements which mean "end of the MOVE statement"), may be in next line(s) too.
in 3- the point '.' has to be excluded from the word
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Oct 11, 2007 4:00 am    Post subject:
Reply with quote

Just curious, Searchman, how would you describe the end product of what you are attempting?
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: Thu Oct 11, 2007 4:08 am    Post subject:
Reply with quote

Searchman,

I don't know COBOL, so I couldn't even attempt to figure out all of the rules for this kind of thing.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Oct 11, 2007 6:03 am    Post subject:
Reply with quote

Hello,

Quote:
Just curious, Searchman, how would you describe the end product of what you are attempting?
Just a guess, but maybe a tool to "clean up" some source code (at least the moves). . .

In addition to the discoveries above there are others including very long literals, multiple MOVEs on one line, preserving indentation for readability, subscripting/indexing, reference modification, preservation of punctuation, and probably a few more.

How many applications/programs/modules need to be passed thru this process?
Back to top
View user's profile Send private message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Thu Oct 11, 2007 12:43 pm    Post subject:
Reply with quote

Dick,

I don't think it depends on the number of programs. The need is to follow a few data from beginning of an application to the end of this (or other) application.
File1 => PGM1 => file2 => PGM2 => file3...
First, I want to associate data from COPY1 of file1 in PGM1 with corresponding data from COPY2 of file2 in PGM1 and then until file3 or more
So, I want to extract ALL "MOVE A TO B" in PGM1, PGM2...

CICS guy, what do you mean by "end product", the end of program ?

Note, as you said Dick, the statement might be complex in theory, but in general in this application the way to write COBOL is nearly the same (look at the file attached).
I think the rules I gave in my last post take almost every case.

Franck, The rules I described are independant of language COBOL except for the reserved words that are nothing but strings (consider a list of strings, e.g. PERFORM and IF with the possibility to extend this list)
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Oct 11, 2007 1:09 pm    Post subject: Reply to: Include afer IFTHEN in DFSORT
Reply with quote

Quote:
The rules I described are independant of language COBOL


not completely true...
for other languages there are many grammar driven shortcuts

what You are trying to implement is some kind of parser,
and, no offense meant - Frank/Alissa, I am not convinced that
any sort product would be the right tool.

For many many languages there is an explicit statement terminator/separator

for cobol things are much more complicated,
sometimes there is an explicit terminator,
in the other cases the end of a statement/(the beginning of the new one)
is marked by a reserved word in the input stream

You are tring to implement a token driven parser,
as opposite to the normal grammar driven parsers

the logic for such a thing for the move statement could be

scan for the MOVE keyword
start to accumulate tokens until END-OF-STATEMENT(BEGINNING-OF-THE-NEW-ONE)
parse the saved string

for the sort approach
You should check for more or less 300 reserved words

I would go for a REXX approach ( many samples available )
for example the rexx parser of the SCLM component
available in ( check Your naming conventions )
"ISP.SISPSAMP(FLMLRCBL)"
could be a good starting point for the overall logic
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Oct 11, 2007 4:40 pm    Post subject: Reply to: Include afer IFTHEN in DFSORT
Reply with quote

MOVE is not the only construct moving things around,
there is also ( correct me if I am wrong ) also the STRING operator

I would definitely go for REXX

I think I' ve got a sample somewhere let me know
and I' ll polish it up and post it
Back to top
View user's profile Send private message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Thu Oct 11, 2007 9:16 pm    Post subject: Reply to: Include afer IFTHEN in DFSORT
Reply with quote

Enrico,

When I said "independant of COBOL" I meant : "you don't have to know COBOL", but, of course, this algorithm wouldn't be correct for another language.

Now, at first approach, it seems to me a COBOL program can product the result. But, I'm careful, may be I'm wrong. But, I say again the "parser" is not to cover all possible cases, only programs of limited applications (where the way to code is similar)

Yes, you're right, UNSTRING can change data, I'll do a search for this statement. But in my applications I don't think there are used to move data from input file to output file.

Otherwise, I'm interested in a REXX parser.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Oct 11, 2007 9:26 pm    Post subject: Reply to: Include afer IFTHEN in DFSORT
Reply with quote

Hi Searchman,

i' ll polish what I have and post it in a while

its' a Rexx script and a file with the cobol keywords in
order to not to change the rexx when the keyword change

I tested with rexx on a mac, but with some mods it should work
on any platform..

the output is of the form :

Code:

program-name line-number from-field to-field
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Fri Oct 12, 2007 12:38 am    Post subject: Reply to: Include afer IFTHEN in DFSORT
Reply with quote

here is the parser, I called it movexref, it' s quite specialized

it's working and has been tested on a mac os x 10.4,
it does not contain any char encoding dependencies

it relies on the naming convention of unix

for I/O it uses the linein/lineout functions
the filename is given at invocation as an arg

it should not be difficult to transform the i/o
to the EXECIO model using ddnames
Back to top
View user's profile Send private message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Mon Oct 29, 2007 2:42 am    Post subject: Reply to: Include afer IFTHEN in DFSORT
Reply with quote

Hi Enrico,

Sorry, I've just seen your Post now because I didn't notice your last reply was on page 2... shame on me !

Thank you for your Rexx script : I'll excute it in a week (I'm on holliday)
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am
No new posts INCLUDE condition questions van bui DFSORT/ICETOOL 1 Thu Jun 30, 2016 9:52 am


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