Application Development and Automation 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: 
Read only

ALV

Former Member
0 Likes
376

I have a report in which , a set of write statements make the header and another set make the item data. The writes are put in two loops , one within the other.

The first loop shows the header data and the loop within that shows the item data.

Is there a way to improve the report by ALV. Can I apply ALV to this situation.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
355

Hi

You can use hierarchical display

This program displays the PO details as the header and the Line details of the corresponding PO and the item details.

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: i_fieldcat TYPE slis_t_fieldcat_alv.

DATA: v_repid LIKE sy-repid.

DATA: g_tabname_header TYPE slis_tabname,

g_tabname_item TYPE slis_tabname,

gs_keyinfo TYPE slis_keyinfo_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.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = v_repid

i_internal_tabname = 'ITEMTAB'

  • 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.

gs_keyinfo-header01 = 'EBELN'.

gs_keyinfo-item01 = 'EBELN'.

g_tabname_header = 'HEADERTAB'.

g_tabname_item = 'ITEMTAB'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

IT_FIELDCAT = i_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

i_tabname_header = g_tabname_header

i_tabname_item = g_tabname_item

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

is_keyinfo = gs_keyinfo

  • IS_PRINT =

  • IS_REPREP_ID =

I_BYPASSING_BUFFER = 'X'

I_BUFFER_ACTIVE = ' '

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab_header = headertab

t_outtab_item = itemtab

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.

2 REPLIES 2
Read only

Former Member
0 Likes
356

Hi

You can use hierarchical display

This program displays the PO details as the header and the Line details of the corresponding PO and the item details.

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: i_fieldcat TYPE slis_t_fieldcat_alv.

DATA: v_repid LIKE sy-repid.

DATA: g_tabname_header TYPE slis_tabname,

g_tabname_item TYPE slis_tabname,

gs_keyinfo TYPE slis_keyinfo_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.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = v_repid

i_internal_tabname = 'ITEMTAB'

  • 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.

gs_keyinfo-header01 = 'EBELN'.

gs_keyinfo-item01 = 'EBELN'.

g_tabname_header = 'HEADERTAB'.

g_tabname_item = 'ITEMTAB'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

IT_FIELDCAT = i_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

i_tabname_header = g_tabname_header

i_tabname_item = g_tabname_item

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

is_keyinfo = gs_keyinfo

  • IS_PRINT =

  • IS_REPREP_ID =

I_BYPASSING_BUFFER = 'X'

I_BUFFER_ACTIVE = ' '

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab_header = headertab

t_outtab_item = itemtab

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.

Read only

0 Likes
355

Thanks for solving the problem.