‎2020 Jun 10 7:49 AM
I am new to Include Programs. I have added them in my main program. The code of main program and Include programs is shown below. I have used Global Structures (zabap_vbrk) and Table Type (zabap_tb_vbrp):
REPORT z_abap_practice_1.
INCLUDE ZABAP_INCLUDE_TOP.
PERFORM get_data.
CALL FUNCTION 'ZABAP_DEMO_FM'
EXPORTING
im_vbeln = p_vbeln
IMPORTING
EX_VBRK = st_vbrk
EX_IT_VBRP = it_vbrp
EXCEPTIONS
INVALID_DOCUMENT = 1
INVALID_CUSTOMER = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
IF sy-subrc Eq 1.
MESSAGE 'Invalid Document' TYPE 'E'.
ENDIF.
ENDIF.
WRITE : / 'Billing Document : ',25 st_vbrk-vbeln,
/ 'Billing Date : ',25 st_vbrk-fkdat,
/ 'Net Value ; ',25 st_vbrk-netwr LEFT-JUSTIFIED,
/ 'Payer : ',25 st_vbrk-kunrg.
SKIP.
WRITE : / 'Item',
15 'Material No.',
30 'Description',
55 'Quantity',
67 'UoM',
75 'Tax Amount'.
LOOP AT it_vbrp INTO wa_vbrp.
WRITE : / wa_vbrp-posnr,
15 wa_vbrp-matnr,
30 wa_vbrp-arktx,
55 wa_vbrp-fkimg LEFT-JUSTIFIED,
67 wa_vbrp-vrkme,
75 wa_vbrp-mwsbp LEFT-JUSTIFIED.
ENDLOOP.
INCLUDE zabap_include_sub.
*&---------------------------------------------------------------------*
*& Include ZABAP_INCLUDE_TOP
*&---------------------------------------------------------------------*
DATA : st_vbrk TYPE zabap_vbrk,
it_vbrp TYPE zabap_tb_vbrp,
wa_vbrp LIKE LINE OF it_vbrp,
it_makt TYPE STANDARD TABLE OF makt.
PARAMETERS p_vbeln TYPE vbeln_vf.
*----------------------------------------------------------------------*
***INCLUDE ZABAP_INCLUDE_SUB.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data.
SELECT * FROM makt INTO TABLE it_makt WHERE matnr EQ p_matnr.
ENDFORM. " GET_DATA
FUNCTION ZABAP_DEMO_FM.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IM_VBELN) TYPE VBELN_VF
*" EXPORTING
*" REFERENCE(EX_VBRK) TYPE ZABAP_VBRK
*" REFERENCE(EX_IT_VBRP) TYPE ZABAP_TB_VBRP
*" EXCEPTIONS
*" INVALID_DOCUMENT
*" INVALID_CUSTOMER
*"----------------------------------------------------------------------
*Fetch Billing Document Header Data.
SELECT SINGLE
vbeln
fkdat
netwr
kunrg
FROM vbrk
INTO EX_VBRK
WHERE vbeln EQ IM_VBELN.
IF sy-subrc IS NOT INITIAL.
RAISE INVALID_DOCUMENT.
ENDIF.
*Fetch Billing Document Item Data.
SELECT vbeln posnr fkimg vrkme matnr arktx mwsbp FROM vbrp
INTO TABLE EX_IT_VBRP
WHERE vbeln EQ IM_VBELN.
ENDFUNCTION.
When I check ZABAP_INCLUDE_TOP for syntax error it gives following error :

Why this error is coming when program type is Include?
‎2020 Jun 10 8:14 AM
hello,
Try activating the main program on SE80, doing a right click on the report z_abap_practice_1.
One advice for better code readability, put all your includes at the top of your report.
regards,
Deenesh
‎2020 Jun 10 8:24 AM
Do not make syntax check only for include - activate all reports with include and then system can check the syntax - it must know the whole report code you write it in that way (no classes, no Subroutine Pool ).
‎2020 Jun 10 9:09 AM
Hi
The sequence of include you have to put together.
REPORT z_abap_practice_1.
INCLUDE ZABAP_INCLUDE_TOP.
INCLUDE zabap_include_sub.
PERFORM get_data.
....
....
Secondly,
You need to activate all together. Using SE80, and right click on the your report name at left panel z_abap_practice_1. -- and activate
‎2020 Jun 11 9:28 AM
I tried to activate through SE80 but it gives error that following statement is not accessible.
PERFORM get_data.
‎2020 Jun 10 9:32 AM
REPORT z_abap_practice_1.
INCLUDE ZABAP_INCLUDE_TOP.
INCLUDE zabap_include_sub. " this includes 'FORM get_data.'
" it has to be declared before the 'PERFORM get_data.' is called !
PERFORM get_data.
" ...
‎2020 Jun 11 9:32 AM
I tried to activate through SE80 but it gives error that following statement is not accessible.
PERFORM get_data.
‎2020 Jun 11 12:52 PM
‎2020 Jun 12 8:44 AM
Yes I did but still error is coming.
REPORT z_abap_practice_1.
INCLUDE ZABAP_INCLUDE_TOP.
INCLUDE ZABAP_INCLUDE_SUB.
PERFORM get_data.
CALL FUNCTION 'ZABAP_DEMO_FM'
EXPORTING
im_vbeln = p_vbeln
IMPORTING
EX_VBRK = st_vbrk
EX_IT_VBRP = it_vbrp
EXCEPTIONS
INVALID_DOCUMENT = 1
INVALID_CUSTOMER = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
IF sy-subrc Eq 1.
MESSAGE 'Invalid Document' TYPE 'E'.
ENDIF.
ENDIF.
WRITE : / 'Billing Document : ',25 st_vbrk-vbeln,
/ 'Billing Date : ',25 st_vbrk-fkdat,
/ 'Net Value ; ',25 st_vbrk-netwr LEFT-JUSTIFIED,
/ 'Payer : ',25 st_vbrk-kunrg.
SKIP.
WRITE : / 'Item',
15 'Material No.',
30 'Description',
55 'Quantity',
67 'UoM',
75 'Tax Amount'.
LOOP AT it_vbrp INTO wa_vbrp.
WRITE : / wa_vbrp-posnr,
15 wa_vbrp-matnr,
30 wa_vbrp-arktx,
55 wa_vbrp-fkimg LEFT-JUSTIFIED,
67 wa_vbrp-vrkme,
75 wa_vbrp-mwsbp LEFT-JUSTIFIED.
ENDLOOP.
It is giving syntax error that the PERFORM statement is not accessible.
‎2020 Jun 12 9:53 AM
H S, it seems there is more coding missing. Where is p_matnr defined? If I include p_matnr along with p_vbeln in the Top-Include, all you have to do, is set the right report event.
Please have a look into event blocks and especially reporting events:
So in conclusion, use the event START-OF-SELECTION to run your report after the selection screen:
REPORT z_abap_practice_1.
INCLUDE zabap_include_top. " contains parameters, therefore report starts with a selection screen
INCLUDE zabap_include_sub.
START-OF-SELECTION. " necessary event to start the process when the report is executed from the selection screen
PERFORM get_data.
" ...