2015 Sep 17 11:42 AM
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
2015 Sep 17 1:37 PM
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.
2015 Sep 17 4:22 PM
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
2015 Sep 18 10:16 AM
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.
2015 Sep 18 10:23 AM
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
2015 Sep 18 10:35 AM
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.
2015 Sep 18 11:00 AM
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.
2015 Sep 18 11:21 AM
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
2015 Sep 18 11:28 AM
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
2015 Sep 18 11:30 AM
2015 Sep 18 12:08 PM
Hello Roy,
Please find attached.
Thanks and Regards,
Muralikrishna Peravali.
2015 Sep 18 12:14 PM
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
2015 Sep 18 12:17 PM
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
2015 Sep 18 12:27 PM
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.
2015 Sep 18 12:35 PM
Where did you put the code. Subscreen PAI? Or Main Screen PAI?
For me empty check should be done in Main Screen PAI.
R
2015 Sep 18 1:46 PM
Hello Surbjeet,
I put this code in the user_command module only.
Thanks and Regards,
Muralikrishna Peravali
2015 Sep 30 8:27 AM
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
2015 Sep 18 12:23 PM
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.
2015 Sep 30 10:46 AM
Hello All,
Any help on this please.
Thanks and Regards,
Muralikrishna Peravali
2015 Sep 30 11:02 AM
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
2015 Sep 30 11:26 AM
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
2015 Sep 30 11:47 AM
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
2015 Sep 30 11:53 AM
Hi Nishant,
I thought of your suggestion but I only quit this because of code review.
Thanks and Regards,
Muralikrishna Peravali
2015 Sep 30 3:03 PM
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.
2015 Sep 30 4:25 PM
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
2015 Sep 30 4:57 PM
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"
2015 Oct 01 7:17 AM
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
2015 Oct 01 8:40 AM
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!!
2015 Oct 01 9:55 AM
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
2015 Oct 04 6:11 PM
Hello All,
Any updates?
Thanks and Regards,
Muralikrishna Peravali
2015 Oct 05 11:02 AM
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.