Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

help plese...

Former Member
0 Kudos
162

Hi Experts,

i want to develop an interactive report in that in my basic list displaying Meterial number folowed by check box, if i select some check boxes in basic list, the respective meteriala will display in my secondary list.

but i need the logic for 2nd list how to find the what are the check boxes whixh i selected.

Thanks in advance,

1 ACCEPTED SOLUTION

Former Member
0 Kudos
124

Hi,

REPORT zdrill_down NO STANDARD PAGE HEADING.

TABLES : eban, makt.

DATA : BEGIN OF itab OCCURS 100,

matnr LIKE eban-matnr,

menge LIKE eban-menge,

END OF itab.

DATA : pick.

SELECT-OPTIONS : s_matnr FOR eban-matnr.

PERFORM get_data.

PERFORM write_list.

AT LINE-SELECTION.

DO.

READ LINE sy-index FIELD VALUE pick.

IF sy-subrc NE 0.

EXIT.

ENDIF.

IF pick EQ 'X'.

PERFORM second_list.

CLEAR : itab-matnr, itab-menge.

ENDIF.

ENDDO.

&----


to get data from datbase table EBAN

-


FORM get_data.

SELECT matnr menge INTO CORRESPONDING FIELDS OF TABLE

itab FROM eban UP TO 20 ROWS WHERE matnr IN s_matnr .

SORT itab BY matnr.

ENDFORM. "get_data

&----


*& Main list

&----


FORM write_list.

LOOP AT itab.

WRITE 😕 pick AS CHECKBOX,

(18) itab-matnr.

HIDE : itab-matnr, itab-menge.

WRITE : sy-vline.

ENDLOOP.

ENDFORM. "write_list

&----


*& Form second_list drill down list

&----


FORM second_list.

WRITE :/(18) itab-matnr,

sy-vline,

(13) itab-menge DECIMALS 0,

sy-vline.

ENDFORM. "second_list

[http://sap-img.com/abap/regarding-runtime-creation-of-check-boxes.htm]

4 REPLIES 4

Former Member
0 Kudos
125

Hi,

REPORT zdrill_down NO STANDARD PAGE HEADING.

TABLES : eban, makt.

DATA : BEGIN OF itab OCCURS 100,

matnr LIKE eban-matnr,

menge LIKE eban-menge,

END OF itab.

DATA : pick.

SELECT-OPTIONS : s_matnr FOR eban-matnr.

PERFORM get_data.

PERFORM write_list.

AT LINE-SELECTION.

DO.

READ LINE sy-index FIELD VALUE pick.

IF sy-subrc NE 0.

EXIT.

ENDIF.

IF pick EQ 'X'.

PERFORM second_list.

CLEAR : itab-matnr, itab-menge.

ENDIF.

ENDDO.

&----


to get data from datbase table EBAN

-


FORM get_data.

SELECT matnr menge INTO CORRESPONDING FIELDS OF TABLE

itab FROM eban UP TO 20 ROWS WHERE matnr IN s_matnr .

SORT itab BY matnr.

ENDFORM. "get_data

&----


*& Main list

&----


FORM write_list.

LOOP AT itab.

WRITE 😕 pick AS CHECKBOX,

(18) itab-matnr.

HIDE : itab-matnr, itab-menge.

WRITE : sy-vline.

ENDLOOP.

ENDFORM. "write_list

&----


*& Form second_list drill down list

&----


FORM second_list.

WRITE :/(18) itab-matnr,

sy-vline,

(13) itab-menge DECIMALS 0,

sy-vline.

ENDFORM. "second_list

[http://sap-img.com/abap/regarding-runtime-creation-of-check-boxes.htm]

Former Member
0 Kudos
124

Hai.

check the example codes.

TABLES:MARA.

DATA:BEGIN OF GT_MARA OCCURS 0,

MATNR LIKE MARA-MATNR,

END OF GT_MARA,

GV_CB,

GV_CBV,

GV_LINES TYPE I,

INDEX TYPE I,

SY_INDEX TYPE I,

GV_LINES1 TYPE I,

MATNR LIKE MARA-MATNR.

SELECT-OPTIONS:S_MATNR FOR MARA-MATNR.

SELECT

MATNR FROM MARA

INTO TABLE GT_MARA

WHERE MATNR IN S_MATNR.

IF SY-SUBRC = 0.

DESCRIBE TABLE GT_MARA LINES GV_LINES.

ENDIF.

LOOP AT GT_MARA.

WRITE:/ GV_CB AS CHECKBOX,

GT_MARA-MATNR.

ENDLOOP.

CLEAR GT_MARA.

WRITE:'Total num of records is ',GV_LINES.

SET PF-STATUS 'DEL'.

AT USER-COMMAND.

IF SY-UCOMM = 'DEL' OR SY-UCOMM = 'PICK'.

DO 50 TIMES.

SY_INDEX = SY-INDEX.

READ LINE SY_INDEX FIELD VALUE GV_CB

GT_MARA-MATNR INTO MATNR.

IF GV_CB = 'X'." AND MATNR IS NOT INITIAL.

  • LOOP AT GT_MARA." WHERE MATNR = MATNR.

  • DELETE GT_MARA.

  • CLEAR GT_MARA.

  • ENDLOOP.

delete gt_mara index sy_index.

ENDIF.

ENDDO.

DESCRIBE TABLE GT_MARA LINES GV_LINES1.

WRITE:'Total num of records is ',GV_LINES1.

CLEAR:GV_LINES .

LOOP AT GT_MARA.

WRITE:/ GT_MARA-MATNR.

ENDLOOP.

ENDIF.

-


for interactive list.

report yh645_secndry_alv.

type-pools: slis.

data: fieldcat type slis_t_fieldcat_alv,

fieldcat_ln like line of fieldcat,

fs_layout type slis_layout_alv,

t_layoout like standard table

of fs_layout.

data: begin of fs_spfli,

carrid type spfli-carrid,

connid type spfli-connid,

countryfr type spfli-countryfr,

cityfrom type spfli-cityfrom,

airpfrom type spfli-airpfrom,

countryto type spfli-countryto,

cityto type spfli-cityto,

airpto type spfli-airpto,

fltime type spfli-fltime,

deptime type spfli-deptime,

arrtime type spfli-arrtime,

distance type spfli-distance,

distid type spfli-distid,

fltype type spfli-fltype,

period type spfli-period,

checkbox,

color(3),

end of fs_spfli.

data:

begin of fs_table,

carrid type spfli-carrid,

connid type spfli-connid,

end of fs_table.

data: begin of fs_sflight,

check,

color(3).

include type sflight.

data:end of fs_sflight.

data:

begin of fs_table1,

carrid type sflight-carrid,

connid type sflight-connid,

fldate type sflight-fldate,

end of fs_table1.

data:

t_spfli like standard table

of fs_spfli.

data:

t_table like standard table

of fs_table.

data:

t_table1 like standard table

of fs_table1.

data:

t_sflight like standard table

of fs_sflight.

data:

t_sbook like standard table

of sbook.

data t_layout type slis_layout_alv.

select *

into corresponding fields of table t_spfli

from spfli.

perform start_list_viewer.

perform get_spfli_details.

&----


*& Form SUB1

&----


  • text

----


  • -->RT_EXTAB text

----


form sub1 using rt_extab type slis_t_extab.

data: flight type slis_extab.

flight-fcode = 'SFLIGHT'.

append flight to rt_extab.

set pf-status 'SFLIGHT'. " EXCLUDING RT_EXTAB.

endform. "SUB1

&----


*& Form START_LIST_VIEWER

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form start_list_viewer .

data: pgm like sy-repid.

pgm = sy-repid.

fs_layout-box_fieldname = 'CHECKBOX'.

fs_layout-info_fieldname = 'COLOR'.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = pgm

i_callback_pf_status_set = 'SUB1'

i_callback_user_command = 'USER_COMMAND'

i_structure_name = 'SPFLI'

is_layout = fs_layout

tables

t_outtab = t_spfli

exceptions

program_error = 1

others = 2.

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. " START_LIST_VIEWER

*******Process Call Back Events (Begin)**************************

form user_command using ucomm like sy-ucomm

selfield type slis_selfield.

case ucomm.

when 'SFLIGHT'.

selfield-refresh = 'X'.

perform get_spfli_details.

select *

from sflight

into corresponding fields of table t_sflight

for all entries in t_table

where carrid eq t_table-carrid

and connid eq t_table-connid.

perform display_sflight.

when 'SBOOK'.

selfield-refresh = 'X'.

perform get_sflight_details.

select *

from sbook

into corresponding fields of table t_sbook

for all entries in t_table1

where carrid eq t_table1-carrid

and connid eq t_table1-connid

and fldate eq t_table1-fldate.

perform display_sbook.

endcase.

endform. "USER_COMMAND

&----


*& Form SUB2

&----


  • text

----


  • -->RT_EXTAB text

----


form sub2 using rt_extab type slis_t_extab.

data: flight type slis_extab.

flight-fcode = 'SBOOK'.

append flight to rt_extab.

set pf-status 'SBOOK'. " EXCLUDING RT_EXTAB.

endform. "SUB2

&----


*& Form DISPLAY_SFLIGHT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_sflight .

data: pgm like sy-repid.

pgm = sy-repid.

clear t_layout.

fs_layout-box_fieldname = 'CHECK'.

fs_layout-info_fieldname = 'COLOR'.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = pgm

i_callback_pf_status_set = 'SUB2'

i_callback_user_command = 'USER_COMMAND'

i_structure_name = 'SFLIGHT'

is_layout = fs_layout

tables

t_outtab = t_sflight

exceptions

program_error = 1

others = 2.

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_SFLIGHT

&----


*& Form GET_SPFLI_DETAILS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_spfli_details .

loop at t_spfli into fs_spfli.

if fs_spfli-checkbox = 'X'.

fs_spfli-color = 'C51'.

fs_spfli-checkbox = '1'.

fs_table-carrid = fs_spfli-carrid.

fs_table-connid = fs_spfli-connid.

append fs_table to t_table.

modify t_spfli from fs_spfli.

endif.

endloop.

endform. " GET_SFLIGHT_DETAILS

&----


*& Form GET_SFLIGHT_DETAILS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_sflight_details .

loop at t_sflight into fs_sflight.

if fs_sflight-check = 'X'.

fs_sflight-color = 'C71'.

fs_sflight-check = '1'.

fs_table1-carrid = fs_sflight-carrid.

fs_table1-connid = fs_sflight-connid.

fs_table1-fldate = fs_sflight-fldate.

append fs_table1 to t_table1.

modify t_sflight from fs_sflight.

endif.

endloop.

endform. " GET_SFLIGHT_DETAILS

&----


*& Form DISPLAY_SBOOK

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_sbook .

data: pgm like sy-repid.

pgm = sy-repid.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = pgm

i_structure_name = 'SBOOK'

tables

t_outtab = t_sbook

exceptions

program_error = 1

others = 2.

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_SBOOK

regards.

sowjanya.b.

Former Member
0 Kudos
124

hi

check this code

tables : ekko,

ekpo.

select-options: s_ebeln for ekko-ebeln.

type-pools: slis.

data: begin of headertab occurs 0,

ebeln like ekko-ebeln,

bstyp like ekko-bstyp,

bsart like ekko-bsart,

statu like ekko-statu,

end of headertab.

data: begin of itemtab occurs 0,

ebeln like ekpo-ebeln,

ebelp like ekpo-ebelp,

matnr like ekpo-matnr,

werks like ekpo-werks,

menge like ekpo-menge,

netpr like ekpo-netpr,

peinh like ekpo-peinh,

netwr like ekpo-netwr,

end of itemtab.

data: begin of level2 occurs 0,

ebeln like ekpo-ebeln,

ebelp like ekpo-ebelp,

matnr like ekpo-matnr,

werks like ekpo-werks,

menge like ekpo-menge,

netpr like ekpo-netpr,

peinh like ekpo-peinh,

netwr like ekpo-netwr,

end of level2.

data: i_fieldcat type slis_t_fieldcat_alv,

i_fieldcat1 type slis_t_fieldcat_alv.

data: v_repid like sy-repid,

v_layout type slis_layout_alv,

v_events type slis_t_event,

v_print type slis_print_alv,

l_fieldcat type slis_fieldcat_alv.

start-of-selection.

v_repid = sy-repid.

select ebeln

bstyp

bsart

statu

into table headertab

from ekko

where ebeln in s_ebeln.

if not headertab[] is initial.

select ebeln

ebelp

matnr

werks

menge

netpr

peinh

netwr

into table itemtab

from ekpo

for all entries in headertab

where ebeln = headertab-ebeln.

endif.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = v_repid

i_internal_tabname = 'HEADERTAB'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = v_repid

i_bypassing_buffer = 'X'

i_buffer_active = ' '

changing

ct_fieldcat = i_fieldcat

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 sy-msgv4.

endif.

loop at i_fieldcat into l_fieldcat.

case l_fieldcat-fieldname.

when 'EBELN'.

l_fieldcat-hotspot = 'X'.

modify i_fieldcat from l_fieldcat.

endcase.

endloop.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

i_bypassing_buffer = 'X'

i_buffer_active = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER_COMMAND'

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

i_save = 'A'

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = headertab

exceptions

program_error = 1

others = 2

.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELDtext

----


form user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

if rs_selfield-fieldname eq 'EBELN'.

case r_ucomm.

when '&IC1'.

read table headertab index rs_selfield-tabindex.

refresh level2.

clear level2.

loop at itemtab where ebeln = headertab-ebeln.

append itemtab to level2.

endloop.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = v_repid

i_internal_tabname = 'LEVEL2'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = v_repid

i_bypassing_buffer = 'X'

i_buffer_active = ' '

changing

ct_fieldcat = i_fieldcat1

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 sy-msgv4.

endif.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

i_bypassing_buffer = 'X'

i_buffer_active = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND =

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat1

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

i_save = 'A'

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = level2

exceptions

program_error = 1

others = 2

.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endcase.

endif.

endform. "USER_COMMAND

Former Member
0 Kudos
124

hi

I will provide a simple piece of code which i ve worked with..check to it that is very much useful to u i hope..

reward if useful


*&---------------------------------------------------------------------*
*& Report  ZCASESTUDY_PURCHASE                                         *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  zcasestudy_purchase  no standard page heading LINE-SIZE 130 LINE-COUNT 60(5)                 .

TABLES :ekko,ekpo,mara.

SELECTION-SCREEN BEGIN OF BLOCK options WITH FRAME TITLE text-001.
SELECT-OPTIONS :  se_ordno FOR ekko-ebeln,           "Purchase order number
                  se_docda FOR ekko-bedat,           "Document date
                  se_docty FOR ekko-bsart,           "Document type
                  se_vendr FOR ekko-llief,           "Vendor
                  se_purgp FOR ekko-ekgrp,           "Purchasing group
                  se_paytm FOR ekko-zterm.           "payment terms
SELECTION-SCREEN END OF BLOCK options.


SELECTION-SCREEN BEGIN OF BLOCK parameters WITH FRAME TITLE text-002.

PARAMETERS     :  p_dcate LIKE ekko-bstyp DEFAULT 'F',       "Document category
                  p_puorgn TYPE ekko-ekorg.                  " Purchasing organisation

SELECTION-SCREEN END OF BLOCK parameters.
******************* VARIABLES********************************
DATA: ekorg1 LIKE ekko-ekorg.
DATA: w_check TYPE c.
DATA: t_ebeln(20) TYPE c.
DATA : l_ebeln TYPE ebeln.

*************************STRUCTURES********************

TYPES: BEGIN OF str_ekko,
         ebeln TYPE ebeln,
         bukrs TYPE bukrs,
         bsart TYPE esart,
         lifnr TYPE elifn,
         zterm TYPE dzterm,
         llief TYPE llief,
       END OF str_ekko.

TYPES : BEGIN OF str_ekpo,

          konnr TYPE konnr,
          banfn TYPE banfn,
          matnr TYPE matnr,
          ktmng TYPE ktmng,
          werks TYPE ewerk,
          lgort TYPE lgort_d,
        END OF str_ekpo.


TYPES: BEGIN OF str_mara,
          matnr TYPE matnr,
          mtart TYPE mtart,
       END OF str_mara.

TYPES: BEGIN OF str_final,
          konnr TYPE konnr,
          banfn TYPE banfn,
          matnr TYPE matnr,
          mtart TYPE mtart,
          ktmng TYPE ktmng,
          werks TYPE ewerk,
          lgort TYPE lgort_d,
          ebeln TYPE ebeln,
        END OF str_final.






******************INTERNAL TABLES*******************


DATA:  it_ekko TYPE STANDARD TABLE OF str_ekko WITH HEADER LINE.
DATA:  it_ekpo TYPE STANDARD TABLE OF str_ekpo WITH HEADER LINE.
DATA:  it_mara TYPE STANDARD TABLE OF str_mara WITH HEADER LINE.
DATA:  it_final TYPE STANDARD TABLE OF str_final WITH HEADER LINE.

*********************SELECTION SCREEN PROCESSES**************
********************INITIALIZATION*************************
INITIALIZATION.
  CLEAR it_ekko.
  REFRESH it_ekko.


AT SELECTION-SCREEN OUTPUT.

  LOOP AT SCREEN.                            "TO FIX THE DOCUMENT TYPE AS 'F'
    IF screen-name = 'P_DCATE'.
      screen-input = 0.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.




AT SELECTION-SCREEN ON p_puorgn.                                          "VALIDATION OF ORGANISATION GROUP
  IF NOT p_puorgn IS INITIAL.
    SELECT SINGLE ekorg FROM t024e INTO ekorg1 WHERE ekorg = p_puorgn.
    IF sy-subrc EQ 0.
      MESSAGE text-003 TYPE 'I'.
    ELSE.
      MESSAGE text-004 TYPE 'E'.
    ENDIF.
  ELSE.
    MESSAGE text-013 TYPE 'E'.
  ENDIF.

END-OF-SELECTION.

*********************************START OF SELECTION**********************
START-OF-SELECTION.



  SELECT ebeln bukrs bsart lifnr zterm llief
            FROM ekko
            INTO TABLE it_ekko
            WHERE  ekorg = p_puorgn AND
                          ebeln IN se_ordno AND
                          bedat IN se_docda AND
                          bsart IN se_docty AND
                          llief IN se_vendr AND
                          ekgrp IN se_purgp AND
                          zterm IN se_paytm AND
                          bstyp = p_dcate.
  IF sy-subrc EQ 0.
    SORT it_ekko BY ebeln.

      WRITE at:  3 text-015,26 text-016,  42 text-017, 61 text-020, 79 text-018  , 96 text-019 .
      ULINE.

    CLEAR it_ekko.

        LOOP AT it_ekko.

            FORMAT COLOR 3.
            FORMAT HOTSPOT ON.

            WRITE:/ w_check AS CHECKBOX,
              sy-vline,
              it_ekko-ebeln,
              23 sy-vline,
              it_ekko-bukrs,
              38 sy-vline,
              it_ekko-bsart,
              59 sy-vline,
              it_ekko-lifnr,
              76 sy-vline,
              it_ekko-zterm,
              96 sy-vline,
              it_ekko-llief,
              115 sy-vline.
        HIDE it_ekko-ebeln.


      FORMAT HOTSPOT OFF.
    ENDLOOP.

  ELSE.

    MESSAGE text-004 TYPE 'E'.

  ENDIF.

  CLEAR it_ekko.


SET PF-STATUS 'DISPLAY'.



AT LINE-SELECTION.

                SELECT konnr
                       banfn
                       matnr
                       ktmng
                       werks
                       lgort
               FROM ekpo
               INTO TABLE it_ekpo
               WHERE ebeln = it_ekko-ebeln.


              IF sy-subrc EQ 0.
                  SORT it_ekpo BY matnr.
              ENDIF.

              PERFORM display USING: 'IT_EKPO-MATNR'.              "Subroutine for matching MATNR & display the output



AT USER-COMMAND.




      CASE sy-ucomm.
          WHEN 'MULTIPLE'.

            DO.
              READ LINE sy-index LINE VALUE INTO t_ebeln.   " reads the contents of a line pointed by SY-INDEX
                  IF NOT sy-subrc EQ 0.
                      EXIT.

                  ELSEIF t_ebeln+0(1) = 'X'.
                      l_ebeln = t_ebeln+4(10).                    "extracting purchase number 4(10)

                          SELECT konnr
                                 banfn
                                 matnr
                                 ktmng
                                 werks
                                 lgort
                           FROM ekpo
                           INTO TABLE it_ekpo
                           WHERE ebeln = l_ebeln.

                              IF NOT sy-subrc EQ 0.
                                    MESSAGE TEXT-014 TYPE 'E'.
                              ELSE.
                                  PERFORM display USING: 'IT_EKPO-MATNR'.               "Subroutine for matching MATNR & display the output

                              ENDIF.

                  ENDIF.
      ENDDO.

  ENDCASE.



*******************************SUBROUTINE FOR MATNR MATCHING AN DISPLAY******************************





*&--------------------------------------------------------------------*
*&      Form  DISPLAY
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->MATNR      text
*---------------------------------------------------------------------*


FORM display USING matnr TYPE matnr.
  CLEAR it_final.
  REFRESH it_final.

      SELECT matnr mtart FROM mara INTO TABLE it_mara WHERE matnr = it_ekpo-matnr.

          LOOP AT it_ekpo.
              READ TABLE it_mara WITH KEY matnr = it_ekpo-matnr.
                  IF sy-subrc EQ 0.
                      it_final-mtart = it_mara-mtart.
                  ENDIF.

                  it_final-konnr = it_ekpo-konnr.
                  it_final-banfn = it_ekpo-banfn.
                  it_final-matnr = it_ekpo-matnr.
                  it_final-ktmng = it_ekpo-ktmng.
                  it_final-werks = it_ekpo-werks.
                  it_final-lgort = it_ekpo-lgort.
                  it_final-ebeln = l_ebeln.

                  APPEND it_final.
          ENDLOOP.



  FORMAT COLOR 1.
  WRITE:/      text-005     , it_ekko-ebeln.
  write: /,
         / '1.',text-006     , it_final-konnr,
         / '2.',text-007     , it_final-banfn.

  SKIP 2.

  ULINE 1(70).

  SET BLANK LINES ON.
  WRITE AT : 2 text-008, 19 text-009, 37 text-010 , 45 text-011 ,62 text-012 .
  SET BLANK LINES ON.
  ULINE 1(72).


  FORMAT COLOR 2.
  LOOP AT it_final.
    WRITE:/

        sy-vline,
          it_final-matnr,
        19 sy-vline,
          it_final-mtart,
        35 sy-vline,
          it_final-ktmng,
        43 sy-vline,
          it_final-werks,
        62 sy-vline,
          it_final-lgort,
        72 sy-vline.
    SET BLANK LINES ON.
    ULINE 1(72) .

  ENDLOOP.

  CLEAR it_final.
  REFRESH it_final.

ENDFORM.                    " end of display


**********************************TOP OF PAGE*************************

TOP-OF-PAGE.
  write  50 text-021 color 6.
  WRITE: / text-022 ,sy-timlo  color 2,
         / text-023 ,sy-mandt color 3,
         /  text-024 ,sy-host color 4  .
**********************************END OF PAGE**************************
END-OF-PAGE.
  WRITE:/ sy-datum.

END-OF-SELECTION.