cancel
Showing results for 
Search instead for 
Did you mean: 

Table control field validation in SAP ABAP

sidda1196
Explorer
0 Kudos

Hi experts! I need to validate a particular input field in the table control.

The scenario is something like: When the user click gives some inputs in table control and click on save certain validation to be done by comparing loaded quantity with balance quantity and throw an error if it exceeds.

*Issue happening is: 

Process After Input. 
Module user_command_500.

loop at gt_item. 
chain. 
field wa_item-loadqty module valiadte_loadqty. 
endchain. 
endloop. 

"Here in my above code, the gate pass is created when user click on SAVE, so the input in table control has to be validated before the Gatepass is generated. My Sy-ucomm is in useer_command_500 where the logic for validations needs to be written but the system captures the loaded qty (Input given in table control) only within loop endloop. So it's like a gatepass is generated and validation is beinh done. 
sveabecker
Community Advocate
Community Advocate
0 Kudos

Hi sidda1196 please don't close a question without getting the right answer. If you have figured out the correct answer, please add it as an answer to your question. Afterwards, you can accept it as the best answer and close the question afterwards. This tutorial can help you to get more information about asking a question: https://developers.sap.com/tutorials/community-qa.html

I have reopened the question to give the community the chance to re-act on your question and provide the correct answer.

Regards, Svea

SAP Community Moderator

raymond_giuseppi
Active Contributor
0 Kudos

You code doesn't use Best Practices, PAI should look like

PROCESS AFTER INPUT.
  MODULE user_command AT EXIT-COMMAND. " Exit/Cancel
  LOOP AT itab.
    CHAIN.
      FIELD record-field1 MODULE check_field1.
      FIELD record-field2.
      MODULE check_record.
    ENDCHAIN.
  ENDLOOP.
  MODULE user_command. "Enter/Save

Accepted Solutions (0)

Answers (1)

Answers (1)

Sandra_Rossi
Active Contributor

If you want to save only if the loop did not produce any error, then call user_command_500 after the loop:

Process After Input. 
  loop at gt_item. 
    chain. 
      field wa_item-loadqty module valiadte_loadqty. 
    endchain. 
  endloop. 
  Module user_command_500.                            " <=== moved after the loop