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

Table Control Validation

former_member267445
Participant
0 Likes
3,874

Hi Gurus,

I have created a custom screen to vendor master and added 2 radio buttons as Yes and No. Below radio buttons I have created a Table Control with 2 fields. Here what I am doing is, when user runs the transaction No is the default radio button and Table control should be in display mode and if user chose the Yes radio button then Table control should be in enable mode. I have done this.

Now, if user chose the Yes radio button and did not enter any values without entering in Table Control I need to through an error message. Actually in screen attributes I have set Recommended. But in one of the table control field there is a SPACE value in F4 option, when I chose SPACE table control is not accepting when I set Recommended.

Is there any solution to over come this?

Thanks and Regards,

Muralikrishna Peravali

30 REPLIES 30
Read only

VenkatRamesh_V
Active Contributor
0 Likes
3,198

Hi Murali,

In Process after Input.

MODULE USER_COMMAND_0100.

MODULE USER_COMMAND_0100 INPUT.

WHEN 'ENTER'.

READ table itab with key vbeln NE ' ' transporting no fields.

if sy-subrc <> 0.

Message 'Enter the values' type 'S' display 'E'. or store the error message to internal table display in popup

LEAVE TO LIST-PROCESSING.

ENDMODULE.   

Hope it helpful,

Regards,

Venkat.

Read only

0 Likes
3,198

Hi,

You can make use of CHAIN.. ENDCHAIN inside the table control to put validation on fields of the table control.

for your reference

LOOP AT tc_itab.

  CHAIN,

     FIELD: <field1>,

                 <field2>.

               .............

     MODULE process_validation. " on change-request/ on input, whatever you can use as per your                                                                  requirement

  ENDCHAIN.

ENDLOOP.

THIS MUST BE DONE IN "PROCESS AFTER INPUT"

thanks

Read only

0 Likes
3,198

Hi Venkat Ramesh,

Thank you for reply. I have tried this one before. As per my knowledge we can not set the option LEAVE to LIST-PROCESSING for sub screens.

Thanks and Regards,

Muralikrishna Peravali.

Read only

0 Likes
3,198

Hi Aditya,

Thank you for reply. Yes, you are correct, when user enters the values in table control but requirement is when Yes radio button chosen and user didn't enter any values in table control then need to through an error message. As per my understanding by debug the code tc_itab will be empty initially so the loop will not execute.

Thanks and Regards,

Muralikrishna Peravali

Read only

0 Likes
3,198

Hi Murali,

Store the  error  message in internal table, display as popup.

Eg: REUSE_ALV_POPUP_TO_SELECT.

OR create variable to hold the subscreen number, create a  blank sub screen.

if the table is  empty, change the screen number to blank screen.

DATA  DYNNR      TYPE SY-DYNNR VALUE '0100',

CALL SUBSCREEN SUB INCLUDING PROGRAMS dynnr. (Screen)

Hope it helpful,

Regards,

Venkat.

Read only

0 Likes
3,198

Hello Venkat,

I have done with out using LEAVE to LIST-PROCESSING. It is working as expected when user chose the Yes radio button and press enter. But when I save the transaction it is directly saving without giving any values in table control.

Thanks and Regards,

Muralikrishna Peravali.

Read only

0 Likes
3,198

Did you put a check for OK_CODE or SY-UCOMM in your code? If yes check if you have the OK_CODE for SAVE added in your IF condition for validation.

R

Read only

0 Likes
3,198

Hello Rudra roy,

Yes, I put a check for OK_CODE as UPDA. Because for SAVE ok code here is UPDA.

Thanks and Regards,

Muralikrishna Peravali

Read only

0 Likes
3,198

Paste your code pls.

Read only

0 Likes
3,198

Hello Roy,

Please find attached.

Thanks and Regards,

Muralikrishna Peravali.

Read only

0 Likes
3,198

You have used Message type S. It won't stop the processing. Also did not paste the full code

Either use Message type "E".

Or skip the next processing by command like LEAVE TO SCREEN 0.

R

Read only

0 Likes
3,198

Hello Roy,

If I use message type as 'E' then table control is going to disable mode. I think LEAVE TO SCREEN 0 is not work for sub screens.

Thanks and Regards,

Muralikrishna Peravali

Read only

0 Likes
3,198

Do no put your code in the main PAI table control loop. Place it in the user_command module.

gv_code = sy-ucomm.

clear sy-ucomm.

  IF gv_code eq gc_t03 or gv_code = gc_upda.

    IF rb_yes eq gc_x.

      IF gt_crt is INITIAL.

        MESSAGE e956(zl).

      ENDIF.

    ENDIF.

  ENDIF.

Read only

0 Likes
3,198

Where did you put the code. Subscreen PAI? Or Main Screen PAI?

For me empty check should be done in Main Screen PAI.

R

Read only

0 Likes
3,198

Hello Surbjeet,

I put this code in the user_command module only.

Thanks and Regards,

Muralikrishna Peravali

Read only

0 Likes
3,198

Hello Rudra Roy,

As I was not feel well, I was on vacation. Sorry for the delay response. I have created a subscreen(9000) using function group and I have attached to Vendor master badi. I have written the logic in 9000 Screen of PAI.

Thanks and Regards,

Muralikrishna Peravali

Read only

VenkatRamesh_V
Active Contributor
0 Likes
3,198

Hi,

Kindly View the code.

TYPES:

       BEGIN OF ty_error,

       msg(30) type c,

       END OF ty_error.

DATA:      it_error TYPE TABLE OF ty_error,

               wa_error TYPE          ty_error,

              it_fcat  TYPE slis_t_fieldcat_alv,

              wa_fcat  TYPE slis_fieldcat_alv,

wa_fcat-fieldname  = 'MSG'.

wa_fcat-seltext_m = 'Error'.

wa_fcat-outputlen = '50'.

APPEND wa_fcat to it_fcat.

IF it_error IS  NOT INITIAL.

wa_fcat-fieldname  = 'MSG'.

wa_fcat-seltext_m = 'Error'.

wa_fcat-outputlen = '50'.

APPEND wa_fcat to it_fcat.

  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

       EXPORTING

         I_TITLE                       = 'Error Details'

        I_SELECTION                   = 'X'

*       I_ALLOW_NO_SELECTION          =

        I_ZEBRA                       = 'X'

        I_SCREEN_START_COLUMN         = 10

        I_SCREEN_START_LINE           = 20

        I_SCREEN_END_COLUMN           = 100

        I_SCREEN_END_LINE             = 30

*       I_CHECKBOX_FIELDNAME          =

*       I_LINEMARK_FIELDNAME          =

*       I_SCROLL_TO_SEL_LINE          = 'X'

         I_TABNAME                     = 'IT_ERROR'

*        I_STRUCTURE_NAME              = 'BAPIRET2'

         IT_FIELDCAT                   =  it_fcat

*       IT_EXCLUDING                  =

*       I_CALLBACK_PROGRAM            =

*       I_CALLBACK_USER_COMMAND       =

*       IS_PRIVATE                    =

*     IMPORTING

*       ES_SELFIELD                   =

*       E_EXIT                        =

       TABLES

         T_OUTTAB                      = it_error

      EXCEPTIONS

        PROGRAM_ERROR                 = 1

        OTHERS                        = 2

               .

     IF SY-SUBRC <> 0.

* Implement suitable error handling here

     ENDIF.

ELSE.

Message 'Data Updated ' Type 'S'.

ENDIF.

Update the error to internal table.

Hope it helpful,

Regards,

Venkat.

Read only

former_member267445
Participant
0 Likes
3,198

Hello All,

Any help on this please.

Thanks and Regards,

Muralikrishna Peravali

Read only

nishantbansal91
Active Contributor
0 Likes
3,198

Hi,

Each table control has one workarea. WA contains value if user has press anything,

So check the W.A, if the WA is initial throw an error message.

Thanks

Nishant

Read only

0 Likes
3,198

Hi Nishant,

Thank you for the reply. If user doesn't enter anything then Loop..Endloop will fail in PAI, so I am not able to do validations over there.

Thanks And Regards,

Muralikrishna Peravali

Read only

0 Likes
3,198

Hi,

Do one thing create one variable in the internal table of the table control.

Put some default value and no need to show the same on the screen.

In this case you loop will never fail and you are able to check the value, this is not the perfect solution it's just kind of temporary solution.


Thanks

Nishant

Read only

0 Likes
3,198

Hi Nishant,

I thought of your suggestion but I only quit this because of code review.

Thanks and Regards,

Muralikrishna Peravali

Read only

0 Likes
3,198

Hi Nishant,

The validation that you are trying to do is not really suited to a PAI table control loop. It would be better to do such validation in the User_Command module where you have access to all the data that was entered/changed. The PAI table control loop is more suited to checking data across the current loop line.

Read only

0 Likes
3,198

Hello Surbjeet,

I am doing the validation in user command. But, when I click SAVE system is throwing an error and table control is greyed out, after that any user interaction(pressing any button on the current screen) system is allowing to save, here I need to enable the table control instead of saving the transaction..

Any suggestion.

Thanks and Regards,

Muralikrishna Peravali

Read only

0 Likes
3,198

Hi,

You can make use of CHAIN.. ENDCHAIN inside the table control to put validation on fields of the table control and avoiding them to grey out on error.

for your reference

LOOP AT tc_itab.

  CHAIN,

     FIELD: <field1>,

                 <field2>.

               .............

     MODULE process_validation. " on change-request/ on input, whatever you can use as per your                                                                  requirement

  ENDCHAIN.

ENDLOOP.

THIS MUST BE DONE IN "PROCESS AFTER INPUT"

Read only

0 Likes
3,198

Hello Aditya,

Thank you for your reply. But here, if user didn't enter any values in table control that time loop will not trigger, so we can not do validation inside loop.

Thanks and Regards,

Muralikrishna Peravali

Read only

0 Likes
3,198

Hi,

for that you can put validation in the following way..

in PAI.

step 1. create a new module in PAI (after table control loop and before the module where you have written the code on SAVE).

step 2. write the following code as per you requirement.

if sy-ucomm (OK_CODE) = 'SAVE' or 'CANCEL' or 'ENTER'.

if it_tab is initial.

message 'ERROR MESSAGE' type 'S" DISPLAY LIKE 'E'.

leave to Screen 0. <<<< it will end the PAI of the screen

endif.

endif.

thanks!!

Read only

0 Likes
3,198

Hi Aditya,

I have tried your suggestion, but here the screen is Subscreen so Leave to Screen will not work for sub screens.

Thanks and Regards,

Muralikrishna Peravali

Read only

former_member267445
Participant
0 Likes
3,198

Hello All,

Any updates?

Thanks and Regards,

Muralikrishna Peravali

Read only

0 Likes
3,198

Hi Murlikrishna,

Instead of setting the attributes as recommended make this as required, Because recommended can be suppressed  without entering any values but required is not.

Also validate your TBC such a way that at once only one row should be enabled and after filling one row enable the proceeding one by one.

By this way standard will handle everything as you like and also don't forget to handle at-exit command.

Regards,

Shadab.