IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Clarification for the issue in the given condition


IBM Mainframe Forums -> FAQ & Basics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mitha

New User


Joined: 01 Dec 2021
Posts: 19
Location: India

PostPosted: Mon Jan 03, 2022 6:31 pm
Reply with quote

Hi All,

I need a clarification for the condition used in my program.

Below is the condition I gave in my program. If the TRC-TRAILER-DATE is less when compared to TRP means ,it should abend. But in my case , it is running opposite.
Code:

IF TRC-TRAILER-DATE < TRP-TRAILER-DATE           
    DISPLAY ' CURRENT TRAILER DATE : '           
                                TRC-TRAILER-DATE
    DISPLAY ' PREVIOUS TRAILER DATE  : '         
                                TRP-TRAILER-DATE
    MOVE 3180   TO  ABEND-CODE                   
    PERFORM 9100-ABEND-PROGRAM THRU 9109-EXIT   
END-IF   


Code:

 CURRENT TRAILER DATE : 01/01/2022                                 
 PREVIOUS TRAILER DATE  : 12/31/2021                               
**************************************************                 
CURR TRAILER DT  < PRIOR TRAILER DT                                 


Here Current trailer date is greater than previous trailer but it is abending. Kindly anyone advice me on this.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Mon Jan 03, 2022 7:16 pm
Reply with quote

It looks like your fields named "...-DATE" are actually defined as character strings: PIC X(10). For some reason your prefer to hide this information from the forum?...

If so, you get what is expected from character strings comparison. In order to compare as dates, the fields must be defined accordingly.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Mon Jan 03, 2022 10:39 pm
Reply with quote

Remove slashes and reformat to use pic 9(8) to compare as numerics.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jan 04, 2022 12:12 am
Reply with quote

unfortunately since it looks like the format is MM/DD/YYYY
getting rid of the slashes will not help

the date must be converted to YYYY/MM/DD with or without the slashes
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Tue Jan 04, 2022 2:28 am
Reply with quote

That’s right .. YYYYMMDD
Back to top
View user's profile Send private message
mitha

New User


Joined: 01 Dec 2021
Posts: 19
Location: India

PostPosted: Tue Jan 04, 2022 2:42 pm
Reply with quote

How to convert? I tried some methods but it is not working correctly. Can anyone share your code snippet
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Tue Jan 04, 2022 10:07 pm
Reply with quote

The code is not particularly difficult:
Code:
05  MDY-DATE.
    10  MDY-MM PIC X(02).
    10         PIC X(01).
    10  MDY-DD PIC X(02).
    10         PIC X(01).
    10  MDY-YY PIC X(04).
05  YMD-DATE.
    10  YMD-YY PIC X(04).
    10  YMD-MM PIC X(02).
    10  YMD-DD PIC X(02).

MOVE MDY-MM TO YMD-MM.
MOVE MDY-DD TO YMD-DD.
MOVE MDY-YY TO YMD-YY.
This removes the slashes from the MDY date.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Tue Jan 04, 2022 10:09 pm
Reply with quote

mitha wrote:
How to convert? I tried some methods but it is not working correctly. Can anyone share your code snippet

What are "some methods you have tried"?

This forum is supposed to point to any wrong usage of mainframe tools and features, but not to present a ready-to-use solution from scratch.
Back to top
View user's profile Send private message
mitha

New User


Joined: 01 Dec 2021
Posts: 19
Location: India

PostPosted: Tue Jan 04, 2022 10:36 pm
Reply with quote

Code:

77  MMDDYY-TRC-DATE               PIC  X(10).
77  YYMMDD-TRC-DATE               PIC  X(8).
77  MMDDYY-TRP-DATE               PIC  X(10).
77  YYMMDD-TRP-DATE               PIC  X(8).

UNSTRING TRC-TRAILER-DATE                       
     DELIMITED BY '/'                           
INTO MMDDYY-TRC-DATE                             
END-UNSTRING       
                             
MOVE MMDDYY-TRC-DATE(1:2) TO YYMMDD-TRC-DATE(5:2)
MOVE MMDDYY-TRC-DATE(3:2) TO YYMMDD-TRC-DATE(7:2)
MOVE MMDDYY-TRC-DATE(5:4) TO YYMMDD-TRC-DATE(1:4)

DISPLAY 'CURRENT TRC DATE : ' YYMMDD-TRC-DATE
   
UNSTRING TRP-TRAILER-DATE                       
     DELIMITED BY '/'                           
INTO MMDDYY-TRP-DATE                             
END-UNSTRING           
                         
MOVE MMDDYY-TRP-DATE(1:2) TO YYMMDD-TRP-DATE(5:2)
MOVE MMDDYY-TRP-DATE(3:2) TO YYMMDD-TRP-DATE(7:2)
MOVE MMDDYY-TRP-DATE(5:4) TO YYMMDD-TRP-DATE(1:4)

DISPLAY 'CURRENT TRP DATE : ' YYMMDD-TRP-DATE 
 
IF YYMMDD-TRC-DATE <  YYMMDD-TRP-DATE           
    DISPLAY ' CURRENT TRAILER DATE : '           
                                TRC-TRAILER-DATE
    DISPLAY ' PREVIOUS TRAILER DATE  : '         
                                TRP-TRAILER-DATE
    MOVE 3180   TO  ABEND-CODE                   
    PERFORM 9100-ABEND-PROGRAM THRU 9109-EXIT   
END-IF                                   

 
Back to top
View user's profile Send private message
mitha

New User


Joined: 01 Dec 2021
Posts: 19
Location: India

PostPosted: Tue Jan 04, 2022 10:39 pm
Reply with quote

I tried the above method but still it is abending. Can anyone share how to make this condition work properly.

TRC-TRAILER-DATE => 01/01/2022
TRP-TRAILER-DATE => 12/31/2021
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Tue Jan 04, 2022 10:47 pm
Reply with quote

mitha wrote:
Code:

77  MMDDYY-TRC-DATE               PIC  X(10).
77  YYMMDD-TRC-DATE               PIC  X(8).
77  MMDDYY-TRP-DATE               PIC  X(10).
77  YYMMDD-TRP-DATE               PIC  X(8).

UNSTRING TRC-TRAILER-DATE                       
     DELIMITED BY '/'                           
INTO MMDDYY-TRC-DATE                             
END-UNSTRING       
                             
MOVE MMDDYY-TRC-DATE(1:2) TO YYMMDD-TRC-DATE(5:2)
MOVE MMDDYY-TRC-DATE(3:2) TO YYMMDD-TRC-DATE(7:2)
MOVE MMDDYY-TRC-DATE(5:4) TO YYMMDD-TRC-DATE(1:4)

DISPLAY 'CURRENT TRC DATE : ' YYMMDD-TRC-DATE
   
UNSTRING TRP-TRAILER-DATE                       
     DELIMITED BY '/'                           
INTO MMDDYY-TRP-DATE                             
END-UNSTRING           
                         
MOVE MMDDYY-TRP-DATE(1:2) TO YYMMDD-TRP-DATE(5:2)
MOVE MMDDYY-TRP-DATE(3:2) TO YYMMDD-TRP-DATE(7:2)
MOVE MMDDYY-TRP-DATE(5:4) TO YYMMDD-TRP-DATE(1:4)

DISPLAY 'CURRENT TRP DATE : ' YYMMDD-TRP-DATE 
 
IF YYMMDD-TRC-DATE <  YYMMDD-TRP-DATE           
    DISPLAY ' CURRENT TRAILER DATE : '           
                                TRC-TRAILER-DATE
    DISPLAY ' PREVIOUS TRAILER DATE  : '         
                                TRP-TRAILER-DATE
    MOVE 3180   TO  ABEND-CODE                   
    PERFORM 9100-ABEND-PROGRAM THRU 9109-EXIT   
END-IF                                   

 

What did you see after the first two DISPLAY statements?
What did you see after the second pair of DISPLAY? (If any)
Back to top
View user's profile Send private message
mitha

New User


Joined: 01 Dec 2021
Posts: 19
Location: India

PostPosted: Tue Jan 04, 2022 10:50 pm
Reply with quote

Only the if condition display is showing in sysout .Other two display , not showing in sysout
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Tue Jan 04, 2022 10:57 pm
Reply with quote

mitha wrote:
Only the if condition display is showing in sysout .Other two display , not showing in sysout

This cannot happen. How the IF condition can be showing, at all??? icon_rolleyes.gif

Find out what is wrong with the first two DISPLAY?
Do you have any compilation warnings, or errors?
Do you have any run-time warnings or errors?
Are you sure you are running the same code produced after compilation of the example you demonstrate?
Add more DISPLAY statements to trace your execution, the simplest ones, like:
Code:
 DISPLAY "Entry point passed."
Back to top
View user's profile Send private message
mitha

New User


Joined: 01 Dec 2021
Posts: 19
Location: India

PostPosted: Tue Jan 04, 2022 11:00 pm
Reply with quote

No compilation error. Working correctly .Ok Will try to find out what the reason. Can you please say me whether this logic is correct or not.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Tue Jan 04, 2022 11:03 pm
Reply with quote

mitha wrote:
No compilation error. Working correctly .Ok Will try to find out what the reason. Can you please say me whether this logic is correct or not.

The logic itself (with one IF only) is correct.
The used data formats are incorrect, or data conversion is wrong.

Trace everything up to more details if needed.
This is the standard way of debugging any code!
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Tue Jan 04, 2022 11:27 pm
Reply with quote

Why do you need all that UNSTRING ? Just use a raw date (field with slashes value) and do as exactly suggested by Robert or at the least simply do reference modification to get into YYYYMMDD format before doing any compare.
Moved to beginners section of the forum
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> FAQ & Basics

 


Similar Topics
Topic Forum Replies
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Issue after ISPF copy to Linklist Lib... TSO/ISPF 1
No new posts Facing ABM3 issue! CICS 3
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top