Display purchase order details using OOPS ALV in ABAP (Fm- for field catlog).
Refer - Steps for OOPS ALV
1. Goto SE38.
2. Give program name and click on create.
3. Give title and click on save.
4. Write code.
REPORT zab_rp_oops_ekko_ekpo.
TABLES: ekko,ekpo.
TYPES: BEGIN OF ty_ekko,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
bstyp TYPE ekko-bstyp,
bsart TYPE ekko-bsart,
END OF ty_ekko.
TYPES: BEGIN OF ty_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
END OF ty_ekpo.
TYPES: BEGIN OF ty_final,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
bstyp TYPE ekko-bstyp,
bsart TYPE ekko-bsart,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
END OF ty_final.
DATA: lt_ekko TYPE TABLE OF ty_ekko,
lr_ekko TYPE ty_ekko,
lt_ekpo TYPE TABLE OF ty_ekpo,
lr_ekpo TYPE ty_ekpo,
lt_final TYPE TABLE OF ty_final,
lr_final TYPE ty_final.
DATA: lt_fieldcat TYPE lvc_t_fcat,
lr_fieldcat TYPE lvc_s_fcat,
lo_container TYPE REF TO cl_gui_custom_container,
lo_grid TYPE REF TO cl_gui_alv_grid.
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
IF s_ebeln IS INITIAL.
MESSAGE 'Pls enter purchasing doc number' TYPE 'E'.
ELSE.
SELECT ebeln
bukrs
bstyp
bsart
FROM ekko
INTO TABLE lt_ekko
WHERE ebeln IN s_ebeln.
ENDIF.
IF lt_ekko IS NOT INITIAL.
SELECT ebeln
ebelp
matnr
werks
FROM ekpo
INTO TABLE lt_ekpo
FOR ALL ENTRIES IN lt_ekko
WHERE ebeln = lt_ekko-ebeln.
ENDIF.
LOOP AT lt_ekko INTO lr_ekko.
lr_final-ebeln = lr_ekko-ebeln.
lr_final-bukrs = lr_ekko-bukrs.
lr_final-bstyp = lr_ekko-bstyp.
lr_final-bsart = lr_ekko-bsart.
LOOP AT lt_ekpo INTO lr_ekpo WHERE ebeln = lr_ekko-ebeln.
lr_final-ebelp = lr_ekpo-ebelp.
lr_final-matnr = lr_ekpo-matnr.
lr_final-werks = lr_ekpo-werks.
APPEND lr_final TO lt_final.
CLEAR lr_final.
ENDLOOP.
ENDLOOP.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZAB_STR_EKKO_EKPO_OOPS'
CHANGING
ct_fieldcat = lt_fieldcat.
CREATE OBJECT lo_container
EXPORTING
container_name = 'CONT'.
CREATE OBJECT lo_grid
EXPORTING
i_parent = lo_container.
CALL METHOD lo_grid->set_table_for_first_display
CHANGING
it_outtab = lt_final
it_fieldcatalog = lt_fieldcat
* it_sort =
* it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
CALL SCREEN '123'.
*************************Create structure******************
* Goto SE11.
* Select data type and give name and select type structure.
* Give fields.
* Check and activate.
*********************End of create structure**************
**********************Call screen 123*********************
* Double clicks on screen number.
* Give description.
* Click on layout.
* Click on custom container button and drag.
* Give name (used in container creation).
********************End of screen 100*********************
Input
Output
****************Thank You********************
Comments
Post a Comment