‎2007 May 14 10:37 AM
Below my code is given. It's my print program.
Now I am selecting my data based on document type in the select-options. Suppose if there is no any data in the coresponding document type then it sholud show the error message. How I will do that.
How I will write the code and where will I insert in the prgram. Plz give me deatils on that.
Regards....
&----
*& Report ZFI_FORM_REPORT
*&
&----
*&
*&
&----
REPORT zfi_form_report.
TABLES: t003.
DATA: itab LIKE zfi_form_printing_structure OCCURS 0 WITH HEADER LINE.
DATA wk_lines.
DATA : BEGIN OF it_hlp OCCURS 0,
belnr LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
budat LIKE bkpf-budat,
bldat LIKE bkpf-bldat,
END OF it_hlp.
DATA : i_bkpf LIKE bkpf OCCURS 0 WITH HEADER LINE.
**************************************************************************
Selection Screen
**************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
*SELECT-OPTIONS : s_blart FOR bkpf-blart OBLIGATORY NO INTERVALS.
SELECT-OPTIONS s_blart FOR t003-blart MATCHCODE OBJECT zdoc_type OBLIGATORY NO INTERVALS no-extension.
PARAMETERS: p_belnr LIKE bseg-belnr,
b_bukrs LIKE bseg-bukrs OBLIGATORY DEFAULT '1000',
g_gjahr LIKE bseg-gjahr.
SELECTION-SCREEN END OF BLOCK b1.
*******************************************************************
F4 Help for belnr
******************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_belnr.
*
DESCRIBE TABLE it_hlp LINES wk_lines.
IF wk_lines = 0.
SELECT belnr gjahr bldat budat INTO CORRESPONDING FIELDS OF it_hlp
FROM bkpf
WHERE bukrs = b_bukrs AND
bstat = ' ' AND
blart IN s_blart.
*
APPEND it_hlp.
*
*
ENDSELECT.
*
ENDIF.
*
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BELNR'
dynprofield = 'P_BELNR'
dynpprog = sy-cprog
dynpnr = sy-dynnr
value_org = 'S'
TABLES
value_tab = it_hlp.
*******************************************************************
Start-of-selection
******************************************************************
START-OF-SELECTION.
DATA: wa_bkpf LIKE bkpf.
IF NOT p_belnr IS INITIAL.
SELECT SINGLE * FROM bkpf INTO wa_bkpf
WHERE belnr = p_belnr AND
blart IN s_blart AND
bukrs = b_bukrs AND
gjahr = g_gjahr.
IF sy-subrc = 0.
SELECT * FROM bseg INTO CORRESPONDING FIELDS OF TABLE itab
WHERE belnr = wa_bkpf-belnr.
ENDIF.
PERFORM display_smartform.
ELSE.
SELECT * FROM bkpf APPENDING TABLE i_bkpf
WHERE bukrs = b_bukrs AND
gjahr = g_gjahr AND
blart IN s_blart AND
bstat = ' '.
LOOP AT i_bkpf INTO wa_bkpf.
SELECT * FROM bseg INTO CORRESPONDING FIELDS OF TABLE itab
WHERE belnr = wa_bkpf-belnr.
PERFORM display_smartform.
ENDLOOP.
ENDIF.
PERFORM display_smartform.
&----
*& Form display_smartform
&----
text
----
--> p1 text
<-- p2 text
----
FORM display_smartform.
CALL FUNCTION '/1BCDWB/SF00000002'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
wa_bkpf = wa_bkpf
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
itab = itab
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "display_SMARTFORM
‎2007 May 14 10:45 AM
Hi Abhay,
Use at selection-screen event.
select ur data into an inter table based on the values given at selection screen.
If table is blank, give an error message.
AT SELECTION -SCREEN.
select * from <table name> into table itab where blart in s_blart .
If itab is initial.
message e001.
endif.
Reward points if helpful.
Regards,
Hemant
‎2007 May 14 10:45 AM
Hi Abhay,
Use at selection-screen event.
select ur data into an inter table based on the values given at selection screen.
If table is blank, give an error message.
AT SELECTION -SCREEN.
select * from <table name> into table itab where blart in s_blart .
If itab is initial.
message e001.
endif.
Reward points if helpful.
Regards,
Hemant
‎2007 May 14 10:46 AM
Hi,
you can display a message in the status bar
MESSAGE E000(ZMC).
E - Error Message - Processing will stop
Instead of E u can use
W - Warning
I - Information - in a POPUP
A - Error with POPUP & Short Dump
create the message using SE93
Message Class : ZMC
Number 000
Put in the reqd text 'No details found'
for which ever internal table you want to check
use this code.
if not itab[] is initial
do whatever processing
else.
MESSAGE E000(ZMC).
endif.
Reward Points if useful.
Regards,
Gaurav
Message was edited by:
Gaurav Parashar