Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Wrong dates getting updated in table

former_member302859
Active Participant
0 Likes
1,444

Hi

I have one code where few fields getting updated wrongly but not on daily bases.

Date should not be lesser than today's date but still its updating some history dates randomly after saving.

please suggest as below logic is on place

MODIFY ZCL_RM_INSPEC FROM FS_TAB.
        COMMIT WORK.
        CONCATENATE 'Checklist Number' CHECKLISTNO 'changed' INTO FS_MESSAGE SEPARATED BY SPACE.
        MESSAGE FS_MESSAGE TYPE 'I' DISPLAY LIKE 'S'.
        LEAVE TO SCREEN 101.
      ELSEIF G_TCODE = 'ZCLAC'.
 
IF ANALYSISDATE IS NOT INITIAL AND
      ( ANALYSISDATE LT CHECKEDDATE OR ANALYSISDATE GT SY-DATUM ).
        MESSAGE 'Invalid Date. Check Entry' TYPE 'I' DISPLAY LIKE 'E'.
        leave TO SCREEN 0100.
      ENDIF.
   IF ( ANALYSISDATE IS INITIAL AND ANALYSISBY IS NOT INITIAL ) OR
           ( ANALYSISDATE IS NOT INITIAL AND ANALYSISBY IS INITIAL ).
        MESSAGE 'Fill in Analysis Completion Date and Sign' TYPE 'I' DISPLAY LIKE 'E'.
        leave TO SCREEN 0100.
      ENDIF.

5 REPLIES 5
Read only

Sathya_Gunasekaran
Contributor
0 Likes
1,059

Is ZCL_RM_INSPECT the table that is getting updated? If yes, The MODIFY statement is before any of your checks though.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,059

Did you know that it is the custom to perform the check before the update?

Read only

0 Likes
1,059

ok thankyou sathya and raymond,

i shall ask my ABAPER to put check condition before modify statement and then will check.

Read only

0 Likes
1,059

If the code is formatted nicely, it becomes clear we don't have all the code (or that it has been improperly copy pasted) - possibly something very relevant is missing.

  MODIFY ZCL_RM_INSPEC FROM FS_TAB.
  COMMIT WORK.
  CONCATENATE 'Checklist Number' CHECKLISTNO 'changed'
         INTO FS_MESSAGE SEPARATED BY SPACE.
  MESSAGE FS_MESSAGE TYPE 'I' DISPLAY LIKE 'S'.
  LEAVE TO SCREEN 101.

ELSEIF G_TCODE = 'ZCLAC'.
  IF ANALYSISDATE IS NOT INITIAL AND
               ( ANALYSISDATE LT CHECKEDDATE OR
                ANALYSISDATE GT SY-DATUM ).
    MESSAGE 'Invalid Date. Check Entry' TYPE 'I' DISPLAY LIKE 'E'.
    leave TO SCREEN 0100.
  ENDIF.
  IF ( ANALYSISDATE IS INITIAL AND ANALYSISBY IS NOT INITIAL ) OR
           ( ANALYSISDATE IS NOT INITIAL AND ANALYSISBY IS INITIAL ).
    MESSAGE 'Fill in Analysis Completion Date and Sign' TYPE 'I' DISPLAY LIKE 'E'.
    leave TO SCREEN 0100.
  ENDIF<br>

The modify only runs if G_TCODE is not ZCLAC. The check only runs if it is.

Read only

0 Likes
1,059

As there is a reference to a dynpro I supposed that this code was in some user_command module. I tend to prefer to put the check in some other modules within FIELD or CHAIN/ENCHAIN statements in PAI and not everything in a single module.

MODULE user_command AT EXIT-COMMAND.
CHAIN.
FIELD ANALYSISDATE.
FIELD ANALYSISBY.
FIELD CHECKEDDATE.
MODULE checker. " eventually ON CHAIN-REQUEST, IF ... THEN MESSAGE TYPE 'E'... 
ENDCHAIN.
MODULE user_command. " CASE OK_CODE...

So I can use real error message and not some DISPLAY LIKE...