2010 Feb 26 6:12 AM
Hi,
I am making a report in which i am taking data from BSIK table, as per below code i have declare two internal tables
IT_BSIK_H
IT_BSIK_S without header line but i want to display error message if both those table are empty and user should be on selection screen
i want to display message as NO record Found.
How to do it.
****************************************************************************
SELECT bukrs lifnr zuonr gjahr belnr budat bldat waers xblnr blart SHKZG MWSKZ dmbtr WRBTR sgtxt saknr zfbdt zterm zbd1t FROM bsik
INTO TABLE IT_BSIK_H where BUKRS IN BUKRS AND
LIFNR IN LIFNR AND
ZTERM IN ZTERM AND
ZFBDT IN ZFBDT AND
BLART IN BLART AND
SAKNR IN SAKNR AND
SHKZG eq 'H'.
SELECT bukrs lifnr zuonr gjahr belnr budat bldat waers xblnr blart SHKZG MWSKZ dmbtr WRBTR sgtxt saknr FROM bsik
INTO TABLE IT_BSIK_S where BUKRS IN BUKRS AND
LIFNR IN LIFNR AND
ZTERM IN ZTERM AND
ZFBDT IN ZFBDT AND
BLART IN BLART AND
SAKNR IN SAKNR AND
SHKZG eq 'S'.
2010 Feb 26 6:24 AM
Hi,
If the internal table is blank the display error message
IF ITAB[] is initial.
message 'No records found' type 'E'.
leave screen.
endif
Regards
Nehruu
Hi,
I am making a report in which i am taking data from BSIK table, as per below code i have declare two internal tables
IT_BSIK_H
IT_BSIK_S without header line but i want to display error message if both those table are empty and user should be on selection screen
i want to display message as NO record Found.
How to do it.
****************************************************************************
SELECT bukrs lifnr zuonr gjahr belnr budat bldat waers xblnr blart SHKZG MWSKZ dmbtr WRBTR sgtxt saknr zfbdt zterm zbd1t FROM bsik
INTO TABLE IT_BSIK_H where BUKRS IN BUKRS AND
LIFNR IN LIFNR AND
ZTERM IN ZTERM AND
ZFBDT IN ZFBDT AND
BLART IN BLART AND
SAKNR IN SAKNR AND
SHKZG eq 'H'.
SELECT bukrs lifnr zuonr gjahr belnr budat bldat waers xblnr blart SHKZG MWSKZ dmbtr WRBTR sgtxt saknr FROM bsik
INTO TABLE IT_BSIK_S where BUKRS IN BUKRS AND
LIFNR IN LIFNR AND
ZTERM IN ZTERM AND
ZFBDT IN ZFBDT AND
BLART IN BLART AND
SAKNR IN SAKNR AND
SHKZG eq 'S'.
2010 Feb 26 6:24 AM
Hello,
I think should be the way you should be doing this:
IF IT_BSIK_H IS INITIAL AND IT_BSIK_S IS INITIAL.
MESSAGE 'No Records Found' TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.BR,
Suhas
2010 Feb 26 6:24 AM
Hi,
As u said erro if both are empty :
SELECT bukrs lifnr zuonr gjahr belnr budat bldat waers xblnr blart SHKZG MWSKZ dmbtr WRBTR sgtxt saknr zfbdt zterm zbd1t FROM bsik
INTO TABLE IT_BSIK_H where BUKRS IN BUKRS AND
LIFNR IN LIFNR AND
ZTERM IN ZTERM AND
* ZFBDT IN ZFBDT AND
BLART IN BLART AND
SAKNR IN SAKNR AND
SHKZG eq 'H'.
*If data not selected
if not sy-subrc is initial.
p_err1 = 'X'.
endif.
SELECT bukrs lifnr zuonr gjahr belnr budat bldat waers xblnr blart SHKZG MWSKZ dmbtr WRBTR sgtxt saknr FROM bsik
INTO TABLE IT_BSIK_S where BUKRS IN BUKRS AND
LIFNR IN LIFNR AND
* ZTERM IN ZTERM AND
* ZFBDT IN ZFBDT AND
BLART IN BLART AND
SAKNR IN SAKNR AND
SHKZG eq 'S'.
*If data not selected
if not sy-subrc is initial.
p_err2 = 'x'.
endif.
start-of-selection.
if p_err1 eq 'X' and p_err2 eq 'X'.
*give error message
endif.
Regards,
Salil
2010 Feb 26 6:24 AM
Hi,
If the internal table is blank the display error message
IF ITAB[] is initial.
message 'No records found' type 'E'.
leave screen.
endif
Regards
Nehruu
2010 Feb 26 6:37 AM
Hi,
Thaks for your reply, i have done changes as given but still if interval table is empty it is going for further operation
find below the code .
*******************************
SELECT bukrs lifnr zuonr gjahr belnr budat bldat waers xblnr blart SHKZG MWSKZ dmbtr WRBTR sgtxt saknr zfbdt zterm zbd1t FROM bsik
INTO TABLE IT_BSIK_H where BUKRS IN BUKRS AND
LIFNR IN LIFNR AND
ZTERM IN ZTERM AND
ZFBDT IN ZFBDT AND
BLART IN BLART AND
SAKNR IN SAKNR AND
SHKZG eq 'H'.
if not sy-subrc is initial.
Flag1 = 'x'.
endif.
SELECT bukrs lifnr zuonr gjahr belnr budat bldat waers xblnr blart SHKZG MWSKZ dmbtr WRBTR sgtxt saknr FROM bsik
INTO TABLE IT_BSIK_S where BUKRS IN BUKRS AND
LIFNR IN LIFNR AND
ZTERM IN ZTERM AND
ZFBDT IN ZFBDT AND
BLART IN BLART AND
SAKNR IN SAKNR AND
SHKZG eq 'S'.
if not sy-subrc is initial.
Flag2 = 'x'.
endif.
if flag1 eq 'X' and flag2 eq 'X'.
message E888 with 'No Data Found'.
LEAVE LIST-PROCESSING.
endif.
*******************************
regards,
zafar
2010 Feb 26 6:42 AM
Hello Zafar,
if flag1 eq 'X' and flag2 eq 'X'.
* message E888 with 'No Data Found'.
message I888 with 'No Data Found'.
LEAVE LIST-PROCESSING.
endif.And what do you mean by "further operation" ?
BR,
Suhas
Edited by: Suhas Saha on Feb 26, 2010 12:13 PM
2010 Feb 26 6:56 AM
Hi,
After seleting data from table bsak further operation means it is selecting vendor name G/L account descripton all this think if first two internal tables are empty ti should not go for all this it should leave the program.
regards,
zafar
2010 Feb 26 7:02 AM
if flag1 eq 'X' and flag2 eq 'X'.
message I888 with 'No Data Found'.
LEAVE Program.
else.
selecr * from kna1...
select description
endif.
or
if itab1[] is initial and itab2[] is initial.
leave program.
else.
...process
endif
2010 Feb 26 7:11 AM
Hi,
I the problem is that even both the flag are set to X it is not executing the message part it is directly going to after end if of message and processing further.
regards,
zafar
2010 Feb 26 7:29 AM
Hello,
How have you defined the flags ?
I think your facing this because the flags are case-sensitive
Check this:
if not sy-subrc is initial.
Flag1 = 'x'. "Lower Case
endif.But in the check you are checking the upper-case
if flag1 eq 'X' and flag2 eq 'X'. "Upper Case
message E888 with 'No Data Found'.
LEAVE LIST-PROCESSING.
endif.I think this might be causing the problem.
BR,
SUhas
2010 Feb 26 7:11 AM
Do like..
IF IT_BSIK_H IS INITIAL AND IT_BSIK_S IS INITIAL.
Message 'No Data Found' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ELSE.
then your code to proceed if data found
ENDIF.
Edited by: Sachin Bidkar on Feb 26, 2010 8:13 AM
2010 Feb 26 7:20 AM
hi
If both flag is set 'X'. Further process
I think you dont want error message.
if flag1 eq 'X' and flag2 eq 'X'.
selecr * from kna1...
select description
endif.
Can you please tell me clear with you scenario...
2010 Feb 26 7:27 AM
Add the following lines to your report :
* TOP
TABLES : sscrfields.
* AT SELECTION-SCREEN ON selopt.
PERFORM check_selopt.
* AT SELECTION-SCREEN
AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN 'ONLI' OR 'PRIN'.
PERFORM read_main_tables.
IF IT_BSIK_H[] IS INITIAL
AND IT_BSIK_SH[] IS INITIAL
MESSAGE e280(s1). " Message will be displayed on selection-screen.
ENDIF.
ENDCASE.
START-OF-SELECTION.
PERFORM read_other_tables.
END-OF-SELECTION.
PERFORM display_data.Also check the behavior of program when message are sent at [Behavior of messages|http://help.sap.com/abapdocu_70/en/ABENABAP_MESSAGES_TYPES.htm] and [Messages in dialog processing |http://help.sap.com/abapdocu_70/en/ABENABAP_MESSAGE_DIALOG.htm]
Regards,
Raymond