Steps
- Go to Transaction Code SE38.
- Enter the program name start's with Y or Z < program name > and click on Create Button.
- Enter the Title.
- Select the Attribute Type as Executable Program.
- Click on SAVE.
- Enter the code
TYPES: BEGIN OF TY_BILL,
VBELN TYPE VBRK-VBELN,
VKORG TYPE VBRK-VKORG,
KUNNR TYPE VBRK-KUNRG,
POSNR TYPE VBRP-POSNR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
END OF TY_BILL.
DATA : WA_BILL TYPE TY_BILL,
IT_BILL TYPE TABLE OF TY_BILL.
DATA : O_CUST TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
O_ALV TYPE REF TO CL_GUI_ALV_GRID.
DATA : IT_FIELD TYPE LVC_T_FCAT,
WA_FIELD TYPE LVC_S_FCAT.
SELECT-OPTIONS : S_VBELN FOR WA_BILL-VBELN.
PERFORM FETCH_DATA USING S_VBELN[] CHANGING IT_BILL.
PERFORM FIELDCAT.
VBELN TYPE VBRK-VBELN,
VKORG TYPE VBRK-VKORG,
KUNNR TYPE VBRK-KUNRG,
POSNR TYPE VBRP-POSNR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
END OF TY_BILL.
DATA : WA_BILL TYPE TY_BILL,
IT_BILL TYPE TABLE OF TY_BILL.
DATA : O_CUST TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
O_ALV TYPE REF TO CL_GUI_ALV_GRID.
DATA : IT_FIELD TYPE LVC_T_FCAT,
WA_FIELD TYPE LVC_S_FCAT.
SELECT-OPTIONS : S_VBELN FOR WA_BILL-VBELN.
PERFORM FETCH_DATA USING S_VBELN[] CHANGING IT_BILL.
- Double click on Subroutine FETCH_DATA .
- Pop-up will appear.
- Click on Yes.
- Enter the subroutine name to create Field catalog.
- Double click on Subroutine name.
- Pop-up will appear.
- Click on Yes.
- Pop-up will appear.
- Select the Include name and click on continue.
- Enter the code.
WA_FIELD-COL_POS = 1.
WA_FIELD-FIELDNAME = 'VBELN'.
WA_FIELD-OUTPUTLEN = 10.
WA_FIELD-SCRTEXT_M = 'BILL DOC '.
WA_FIELD-KEY = 'X'.
WA_FIELD-HOTSPOT = 'X'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 2.
WA_FIELD-FIELDNAME = 'VKORG'.
WA_FIELD-OUTPUTLEN = '10'.
WA_FIELD-SCRTEXT_M = 'SALES ORGANISATION'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 3.
WA_FIELD-FIELDNAME = 'KUNRG'.
WA_FIELD-OUTPUTLEN = 18.
WA_FIELD-SCRTEXT_M = 'CUSTOMER'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 4.
WA_FIELD-FIELDNAME = 'POSNR'.
WA_FIELD-OUTPUTLEN = 6.
WA_FIELD-SCRTEXT_M = 'ITEM NUMBER'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 5.
WA_FIELD-FIELDNAME = 'MATNR'.
WA_FIELD-OUTPUTLEN = 18.
WA_FIELD-SCRTEXT_M = 'MATERIAL NUMBER'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 6.
WA_FIELD-FIELDNAME = 'ARKTX'.
WA_FIELD-OUTPUTLEN = 40.
WA_FIELD-SCRTEXT_M = 'MATERIAL DESCRIPTION'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-FIELDNAME = 'VBELN'.
WA_FIELD-OUTPUTLEN = 10.
WA_FIELD-SCRTEXT_M = 'BILL DOC '.
WA_FIELD-KEY = 'X'.
WA_FIELD-HOTSPOT = 'X'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 2.
WA_FIELD-FIELDNAME = 'VKORG'.
WA_FIELD-OUTPUTLEN = '10'.
WA_FIELD-SCRTEXT_M = 'SALES ORGANISATION'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 3.
WA_FIELD-FIELDNAME = 'KUNRG'.
WA_FIELD-OUTPUTLEN = 18.
WA_FIELD-SCRTEXT_M = 'CUSTOMER'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 4.
WA_FIELD-FIELDNAME = 'POSNR'.
WA_FIELD-OUTPUTLEN = 6.
WA_FIELD-SCRTEXT_M = 'ITEM NUMBER'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 5.
WA_FIELD-FIELDNAME = 'MATNR'.
WA_FIELD-OUTPUTLEN = 18.
WA_FIELD-SCRTEXT_M = 'MATERIAL NUMBER'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 6.
WA_FIELD-FIELDNAME = 'ARKTX'.
WA_FIELD-OUTPUTLEN = 40.
WA_FIELD-SCRTEXT_M = 'MATERIAL DESCRIPTION'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
- Call Screen.
- Double click on Screen Number.
- Pop-up will appear.
- Click on Yes.
- Enter the short description.
- Click on Layout Button.
- Click on Custom Container.
- Drag the Custom Container and enter the custom container name.
- Click on Back Button.
- Enable the PBO and PAI modules.
- Double click on PBO module.
- Pop-up will appear.
- Click on Yes.
- Select the Include and click on Continue.
- Pop-up will appear.
- Click on Yes.
- Looks like,
- Enable PF-status and Enter the name.
- Double click on the name.
- Pop-up will appear.
- Click on Yes.
- Pop-up will appear.
- Enter the short text and click continue.
- Screen looks like,
- Expand Function Keys and Enter the function keys.
- Save -> Check -> Activate.
- Click on Back.
- Enter the code.
IF O_CUST IS NOT BOUND.
create object o_cust
exporting
* parent =
container_name = 'CUST'
* style =
* lifetime = lifetime_default
* repid =
* dynnr =
* no_autodef_progid_dynnr =
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
create object o_alv
exporting
* i_shellstyle = 0
* i_lifetime =
i_parent = O_CUST
* i_appl_events = space
* i_parentdbg =
* i_applogparent =
* i_graphicsparent =
* i_name =
* i_fcat_complete = space
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 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.
call method o_alv->set_table_for_first_display
* exporting
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
* i_structure_name =
* is_variant =
* i_save =
* i_default = 'X'
* is_layout =
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
changing
it_outtab = IT_BILL
it_fieldcatalog = IT_FIELD
* it_sort =
* it_filter =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
ENDIF.
- Click on Save and Click on BACK button.
- Click on Save and click on Back Button.
Source Code
TYPES: BEGIN OF TY_BILL,
VBELN TYPE VBRK-VBELN,
VKORG TYPE VBRK-VKORG,
KUNNR TYPE VBRK-KUNRG,
POSNR TYPE VBRP-POSNR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
END OF TY_BILL.
DATA : WA_BILL TYPE TY_BILL,
IT_BILL TYPE TABLE OF TY_BILL.
DATA : O_CUST TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
O_ALV TYPE REF TO CL_GUI_ALV_GRID.
DATA : IT_FIELD TYPE LVC_T_FCAT,
WA_FIELD TYPE LVC_S_FCAT.
SELECT-OPTIONS : S_VBELN FOR WA_BILL-VBELN.
START-OF-SELECTION.
PERFORM FETCH_DATA USING S_VBELN[] CHANGING IT_BILL.
PERFORM FIELDCAT.
CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module STATUS_9000 output.
SET PF-STATUS 'ZOOBAR'.
* SET TITLEBAR 'xxx'.
IF O_CUST IS NOT BOUND.
create object o_cust
exporting
* parent =
container_name = 'CUST'
* style =
* lifetime = lifetime_default
* repid =
* dynnr =
* no_autodef_progid_dynnr =
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
create object o_alv
exporting
* i_shellstyle = 0
* i_lifetime =
i_parent = O_CUST
* i_appl_events = space
* i_parentdbg =
* i_applogparent =
* i_graphicsparent =
* i_name =
* i_fcat_complete = space
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 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.
call method o_alv->set_table_for_first_display
* exporting
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
* i_structure_name =
* is_variant =
* i_save =
* i_default = 'X'
* is_layout =
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
changing
it_outtab = IT_BILL
it_fieldcatalog = IT_FIELD
* it_sort =
* it_filter =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
ENDIF.
endmodule. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module USER_COMMAND_9000 input.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
endmodule. " USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
*& Form FETCH_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_S_VBELN[] text
* <--P_IT_BILL text
*----------------------------------------------------------------------*
form FETCH_DATA using p_s_vbeln like s_vbeln[]
changing p_it_bill like it_bill .
SELECT A~VBELN
VKORG
KUNRG
POSNR
MATNR
ARKTX INTO TABLE p_it_bill FROM VBRK AS A INNER JOIN VBRP AS B
ON B~VBELN = A~VBELN WHERE A~VBELN IN p_s_vbeln.
endform. " FETCH_DATA
*&---------------------------------------------------------------------*
*& Form FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form FIELDCAT .
WA_FIELD-COL_POS = 1.
WA_FIELD-FIELDNAME = 'VBELN'.
WA_FIELD-OUTPUTLEN = 10.
WA_FIELD-SCRTEXT_M = 'BILL DOC '.
WA_FIELD-KEY = 'X'.
WA_FIELD-HOTSPOT = 'X'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 2.
WA_FIELD-FIELDNAME = 'VKORG'.
WA_FIELD-OUTPUTLEN = '10'.
WA_FIELD-SCRTEXT_M = 'SALES ORGANISATION'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 3.
WA_FIELD-FIELDNAME = 'KUNRG'.
WA_FIELD-OUTPUTLEN = 18.
WA_FIELD-SCRTEXT_M = 'CUSTOMER'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 4.
WA_FIELD-FIELDNAME = 'POSNR'.
WA_FIELD-OUTPUTLEN = 6.
WA_FIELD-SCRTEXT_M = 'ITEM NUMBER'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 5.
WA_FIELD-FIELDNAME = 'MATNR'.
WA_FIELD-OUTPUTLEN = 18.
WA_FIELD-SCRTEXT_M = 'MATERIAL NUMBER'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
WA_FIELD-COL_POS = 6.
WA_FIELD-FIELDNAME = 'ARKTX'.
WA_FIELD-OUTPUTLEN = 40.
WA_FIELD-SCRTEXT_M = 'MATERIAL DESCRIPTION'.
APPEND WA_FIELD TO IT_FIELD.
CLEAR WA_FIELD.
endform. " FIELDCAT
No comments:
Post a Comment