Form
Form
Form
*&
Form f_clear_refresh
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
FORM f_clear_refresh .
* Celar the data
CLEAR:wa_vbrk,
wa_vbrp,
wa_final,
wa_layout,
wa_fieldcat.
* Refresh the data
REFRESH:gt_vbrk,
gt_vbrp,
gt_final,
gt_fieldcat,
gt_list_header ,
gt_event.
ENDFORM.
" f_clear_refres
h
*&--------------------------------------------------------------------*
*&
Form f_pop_fieldcat
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*---------------------------------------------------------------------*
FORM f_pop_fieldcat .
DATA:lv_col TYPE i.
* 1st Way-Using the FM
*CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE
'
** EXPORTING
**
I_PROGRAM_NAME
=
**
I_INTERNAL_TABNAME
=
" Internal table name
** Note: LIKE should be used to refer the fi
elds while defining the types
**
I_STRUCTURE_NAME
=
" DBTABLE/DB Structure name
**
I_CLIENT_NEVER_DISPLAY
= 'X'
**
I_INCLNAME
=
**
I_BYPASSING_BUFFER
=
**
I_BUFFER_ACTIVE
=
* CHANGING
*
ct_fieldcat
= gt_field
cat
** EXCEPTIONS
**
INCONSISTENT_INTERFACE
= 1
**
PROGRAM_ERROR
= 2
**
OTHERS
= 3
*
.
*IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER
SY-MSGNO
**
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 S
Y-MSGV4.
*ENDIF.
lv_col.
= 'FKIMG'.
'GT_FINAL'.
= 'Actual Invoiced Q
= 'Actual Invoiced Q
= 'Actual Invoiced Q
gt_fieldcat.
---------------------------*
* --> p1
text
* <-- p2
text
*---------------------------------------------------------------------*
FORM f_display_alv .
IF NOT gt_final IS INITIAL.
IF p_grid EQ 'X'.
* CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program
= sy-repid
i_callback_pf_status_set = 'F_PF_S
TATUS_SET' "Dynamic sub routine
* Dynamic subroutine call for an event USER_
COMMAND
i_callback_user_command = 'F_USER
_COMMAND'
* Dynamic subroutine call for an event TOP_O
F_PAGE for GRID only
*
i_callback_top_of_page
= 'F_TOP
-OF-PAGE'
*NOTE:1. The parameter 'i_callback_top_of_pa
ge' is not there
*
for ALV List and Heirarchical ALV
*
2. These call back parameters are not
there for
*
Blocked ALV
is_layout
= wa_layo
ut
it_fieldcat
= gt_fiel
dcat
it_events
= gt_event
TABLES
t_outtab
= gt_fina
l[]
EXCEPTIONS
program_error
= 1
OTHERS
= 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NU
MBER sy-msgno
WITH sy-msgv1 sy-msgv2 symsgv3 sy-msgv4.
ENDIF.
ELSE.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program
= sy-repid
i_callback_pf_status_set = 'F_PF_S
TATUS_SET'
"Dynamic sub routine see FOR
M below
i_callback_user_command = 'USER_C
OMMAND'
"Dynamic sub routine see FORM
below
is_layout
= wa_layo
ut
it_fieldcat
= gt_fiel
dcat
it_events
= gt_event
TABLES
t_outtab
= gt_fina
l[]
EXCEPTIONS
program_error
= 1
OTHERS
= 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NU
MBER sy-msgno
wa_fieldcat-col_pos =
wa_fieldcat-fieldname
wa_fieldcat-tabname =
wa_fieldcat-seltext_m
APPEND wa_fieldcat TO
p_col_pos.
= p_field.
p_field.
= p_label.
p_gt_fieldcat.
ENDFORM.
" f_populate_fie
ldcat
*&--------------------------------------------------------------------*
*&
Form F_LAYOUT
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*---------------------------------------------------------------------*
FORM f_layout .
*declaration of local data
CONSTANTS: lc_x TYPE c VALUE 'X'.
* wa_layout-zebra = lc_x.
wa_layout-no_input = lc_x.
wa_layout-colwidth_optimize = lc_x.
wa_layout-detail_popup = lc_x.
wa_layout-confirmation_prompt = lc_x.
ENDFORM.
" F_LAYOUT
**------------------------------------------------------------------*
** Form TOP-OF-PAGE *
**------------------------------------------------------------------*
** ALV Report Header *
**------------------------------------------------------------------*
FORM f_top_of_page.
*ALV Header declarations
DATA:lt_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
lv_line LIKE wa_header-info,
lv_count(10) TYPE c.
*****>>>1. use an event TOP_OF_PAGE
****>>>>2.Populate the Headings
* Title
wa_header-typ = 'H'.
wa_header-info = 'Billing Report'.
APPEND wa_header TO lt_header.
CLEAR wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays d
ate
APPEND wa_header TO lt_header.
CLEAR: wa_header.
* Total No. of Records Selected
DESCRIBE TABLE gt_final LINES gv_count.
MOVE gv_count TO lv_count.
CONCATENATE 'Total No. of Records Selected
:' lv_count
INTO lv_line SEPARATED BY space.
wa_header-typ = 'A'.
wa_header-info = lv_line.
APPEND wa_header TO lt_header.
CLEAR: wa_header, lv_line.
****>>>3. Diaply the populated Headings and
Logo
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = lt_header " Headi
ngs
i_logo
= 'ENJOYSAP_LOGO'.
"Image name
ENDFORM.
"top-of-page
*&--------------------------------------------------------------------*
*&
Form SET-PF-STATUS
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
FORM f_pf_status_set USING p_extab TYPE slis
_t_extab.
*** Declaration of Local Data
DATA:ls_extab LIKE LINE OF p_extab.
* Exclude unwanted FCT codes
ls_extab-fcode = '&NFO'.
APPEND ls_extab TO p_extab.
ls_extab-fcode = '&CRB'.
APPEND ls_extab TO p_extab.
ls_extab-fcode = '&CRL'.
APPEND ls_extab TO p_extab.
ls_extab-fcode = '&CRR'.
---------------------------*
*&
Form f_get_vbrk
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*---------------------------------------------------------------------*
FORM f_get_vbrk .
* Get the required data from VBRK
SELECT vbeln
fkart
fktyp
vbtyp
waerk
vkorg
netwr
FROM vbrk
INTO TABLE gt_vbrk
WHERE vbeln IN s_vbeln.
ENDFORM.
" f_get_vbrk
*&--------------------------------------------------------------------*
*&
Form f_get_vbrp
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*-------------------------------------------
---------------------------*
FORM f_get_vbrp .
* Get the Required data from VBRP
IF NOT gt_vbrk[] IS INITIAL.
SELECT vbeln
posnr
fkimg
vrkme
meins
INTO TABLE gt_vbrp
FROM vbrp
FOR ALL ENTRIES IN gt_vbrk
WHERE vbeln EQ gt_vbrk-vbeln.
ENDIF.
ENDFORM.
" f_get_vbrp
*&--------------------------------------------------------------------*
*&
Form f_final_data
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*---------------------------------------------------------------------*
FORM f_final_data .
* Sort the Internal tables
SORT:gt_vbrp.
LOOP AT gt_vbrp INTO wa_vbrp.
* Move the req.fields from gt_vbrp into GT_F
INAL
wa_final-posnr = wa_vbrp-posnr.
wa_final-fkimg = wa_vbrp-fkimg.
wa_final-vrkme = wa_vbrp-vrkme.
wa_final-meins = wa_vbrp-meins.
* Access the data from GT_VBRK
READ TABLE gt_vbrk INTO wa_vbrk WITH KEY
vbeln = wa_vbrp-vbeln
BINARY SEARCH.
*
OR
*
READ TABLE gt_vbrk INTO wa_vbrk INDEX s
y-tabix.
IF sy-subrc EQ 0.
* Move the req.fields from gt_vbrk into GT_F
INAL
MOVE:wa_vbrk-vbeln TO wa_final-vbeln,
wa_vbrk-fkart TO wa_final-fkart,
wa_vbrk-fktyp TO wa_final-fktyp,
wa_vbrk-vbtyp TO wa_final-vbtyp,
wa_vbrk-waerk TO wa_final-waerk,
wa_vbrk-netwr TO wa_final-netwr,
wa_vbrk-vkorg TO wa_final-vkorg.
ENDIF.
* Append an Internal table GT_FINAL
APPEND wa_final TO gt_final.
* Clear the work areas
CLEAR:wa_vbrk,
wa_vbrp,
wa_final.
ENDLOOP.
ENDFORM.
" f_final_data
*&--------------------------------------------------------------------*
*&
Form f_validate_vbeln
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*---------------------------------------------------------------------*
FORM f_validate_vbeln .
* Define the local data
TYPES:BEGIN OF ltyp_vbeln,
vbeln TYPE vbeln_vf,
END OF ltyp_vbeln.
DATA:lt_vbeln TYPE SORTED TABLE OF ltyp_vb
eln WITH UNIQUE KEY vbeln.
* Check whether the given value exists or no
t
SELECT vbeln
FROM vbrk
INTO TABLE lt_vbeln
WHERE vbeln IN s_vbeln.
IF lt_vbeln[] IS INITIAL.
* Messaeg-Please provide a valid Input
MESSAGE text-002 TYPE 'E'.
ENDIF.
ENDFORM.
" f_validate_vbe
ln
*&--------------------------------------------------------------------*
*&
Form f_event_pop
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*---------------------------------------------------------------------*
FORM f_event_pop .
*2nd Way-Advisable
wa_event-name = 'TOP_OF_PAGE'. " Event nam
e
wa_event-form = 'F_TOP_OF_PAGE'. "Dynamic
Sub routine name
APPEND wa_event TO gt_event.
* 3rd Way
* Events
* CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
*
EXPORTING
*
i_list_type
= 0
*
IMPORTING
*
et_events
= gt_event
*
EXCEPTIONS
*
list_type_wrong = 1
*
OTHERS
= 2.
* IF sy-subrc <> 0.
*
MESSAGE ID sy-msgid TYPE sy-msgty NUMBE
R sy-msgno
*
WITH sy-msgv1 sy-msgv2 sy-msgv3
sy-msgv4.
* ENDIF.
*
** Populate the dynamic form names
* LOOP AT gt_event INTO wa_event.
*
CASE wa_event-name.
*
WHEN 'TOP_OF_PAGE'.
*
wa_event-form = 'F_TOP_OF_PAGE'.
*
MODIFY gt_event FROM wa_event TRANS
PORTING form.
*
ENDCASE.
* ENDLOOP.
ENDFORM.
" f_event_pop