‎2011 Oct 10 6:00 AM
Hi,
I am now developing a program which needs comparison to string. There are several checkbox on the selection screen, when the checkbox is checked, data contains certain string needed to pass the authority checking. Here are my codes:
NOTE: data type : lifnr_c type c(10).
if ( P_402 = 'X' and inven_data-lifnr_c CS '402' ) or
( P_403 = 'X' and inven_data-lifnr_c CS '403' ) or
( P_410 = 'X' and inven_data-lifnr_c CS '410' ).
allow = 'X'.
endif.First of all, does the code correct syntax-wise?
Also, I am sure there are some data contains '402', '403' or '410', however, I can get no result in this case, what will be possible errors?
Thanks,
Regards,
Mandy
‎2011 Oct 10 7:16 AM
Hi,
Syntax wise the code is correct.
if ( P_402 = 'X' and inven_data-lifnr_c CS '402' ) or
( P_403 = 'X' and inven_data-lifnr_c CS '403' ) or
( P_410 = 'X' and inven_data-lifnr_c CS '410' ).
allow = 'X'.
endif.Here for two condition you have put AND operator so both should be true, in any of the three conditions. Then only you will get result. For eg: suppose inven_data-lifnr_c CS '402' is true and checkbox you have selected is P_410. Then no result will come. Check in debugging.
Try like below also.
if ( P_402 = 'X' and inven_data-lifnr_c CS '402 ' ) or
( P_403 = 'X' and inven_data-lifnr_c CS '403 ' ) or
( P_410 = 'X' and inven_data-lifnr_c CS '410 ' ).
allow = 'X'.
endif.If this is not working, try with string operator CP. Check this [link |http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3516358411d1829f0000e829fbfe/content.htm] for more details.
if ( P_402 = 'X' and inven_data-lifnr_c CP '*402* ' ) or
( P_403 = 'X' and inven_data-lifnr_c CP '*403*' ) or
( P_410 = 'X' and inven_data-lifnr_c CP '*410*' ).
allow = 'X'.
endif.
‎2011 Oct 10 7:54 AM
‎2011 Oct 10 7:48 AM
Hi Mandy,
the issue may be caused by field inven_data-lifnr ! What is the content of the field while debugging your code ? Is inven_data a structure or the header line of an internal table ?
Regards,
Klaus
‎2011 Oct 10 8:11 AM
Dear Klaus,
The INVEN_DATA is declare as follow:
INVEN_DATA type ZABC occurs 0 with header line,While ZABC is the customized table.
When runniing the debug mode the data type : char (10)
value '0000004021', '0000004031' or '0000004101'
Regards,
Mandy
Edited by: Mandy Au on Oct 10, 2011 10:01 AM
‎2011 Oct 10 9:19 AM
Hi Mandy,
this look fine. What is the exact definition of your P_402, P_403 and P_403 parameters.
Are they type FLAG or c(1) ? Are they defines as checkbox ?
While debugging, which one is marked, or do you mark all of them ?
Regards,
Klaus
‎2011 Oct 10 9:35 AM
Dear Klaus,
All are checkbox:
PARAMETERS: p_datum type sy-datum default sy-datum OBLIGATORY ,
p_402 AS CHECKBOX DEFAULT 'X',
p_403 AS CHECKBOX DEFAULT 'X',
p_410 AS CHECKBOX DEFAULT 'X'.All parameters return 'X' when the program is run.
Regards,
Mandy
‎2011 Oct 10 9:47 AM
Hello Mandy,
In which event have you written this IF ... ENDIF block? (For e.g., AT SELECTION-SCREEN, START-OF-SELECTION etc.)
Also in your code you're accessing the header-line of the internal table, are you looping on the internal table as well?
BR,
Suhas
PS: Avoid using internal table with HEADER LINE!
‎2011 Oct 10 9:54 AM
Dear Suhas,
This is the process after all selection ends.
After the END-OF-SELECTION.
I know, however, this is some enhancement that I have no choice but an intenral table with header line. >.<
Regards,
Mandy