Skip to Content
0
Former Member
Feb 14, 2007 at 09:22 AM

reuse alv hierseq list display pgm doubt

253 Views

can anyone tell me s my coding s write or not becos in the report output i cannot view the line item details but it s gettign populated in the itab

REPORT ZTEST_1.

TABLES: KNB1,BSID.

*

TYPE-POOLS: SLIS.

*

*

*TYPES:BEGIN OF TYP_OUTPUT.

  • INCLUDE STRUCTURE ZRFPOSXEXT.

*TYPES:END OF TYP_OUTPUT.

TYPES:BEGIN OF TYP_BSEG,

bukrs like bsid-bukrs,

kunnr like bsid-kunnr,

zuonr like bsid-zuonr,

belnr like bsid-belnr,

bldat like bsid-bldat,

xblnr like bsid-xblnr,

blart like bsid-blart,

dmbtr like bsid-dmbtr,

aufnr like bsid-aufnr,

vbel2 like bsid-vbel2,

posn2 like bsid-posn2,

END OF TYP_BSEG.

TYPES:BEGIN OF TYP_VBRP,

VBELN LIKE VBRP-VBELN,

AUBEL LIKE VBRP-AUBEL,

AUPOS LIKE VBRP-AUPOS,

VKGRP LIKE VBRP-VKGRP,

TDNAME LIKE STXH-TDNAME,

TDLINE LIKE TLINE-TDLINE,

END OF TYP_VBRP.

data: wa_vbrp type typ_vbrp.

DATA:

*GT_HEADER_TABLE TYPE TYP_OUTPUT OCCURS 0 WITH HEADER LINE,

GT_ITEM_TABLE TYPE TYP_VBRP OCCURS 0 WITH HEADER LINE.

DATA: IT_BSEG TYPE TYP_BSEG OCCURS 0 WITH HEADER LINE.

  • Define fieldcatalog

DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

  • Callback program

DATA: G_REPID LIKE SY-REPID.

  • List layout description

DATA: GS_LAYOUT TYPE SLIS_LAYOUT_ALV.

  • Group order criterium

DATA: GS_KEYINFO TYPE SLIS_KEYINFO_ALV.

  • Layout *

  • Definition for field choice screen **

GS_LAYOUT-HEADER_TEXT = 'HEADER'.

GS_LAYOUT-ITEM_TEXT = 'ITEM'.

GS_LAYOUT-DEFAULT_ITEM = 'X'.

*

  • Initialization fieldcatalog ***

G_REPID = SY-REPID.

PERFORM FIELDCAT_INIT USING GT_FIELDCAT[].

*

  • Data selection ***

PERFORM SELECT_DATA.

*

  • Define keyinfo as sort group definition ***

CLEAR GS_KEYINFO.

GS_KEYINFO-HEADER01 = 'BELNR'. "idenify header and item

GS_KEYINFO-ITEM01 = 'VBELN'.

  • Call function to list display (hier-seq) ***

*

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

IS_LAYOUT = GS_LAYOUT

IT_FIELDCAT = GT_FIELDCAT[]

  • I_TABNAME_HEADER = 'GT_HEADER_TABLE'

I_TABNAME_HEADER = 'IT_BSEG'

I_TABNAME_ITEM = 'GT_ITEM_TABLE'

  • I_STRUCTURE_NAME_HEADER = <STRUCTURE_NAME_HEADER>

  • I_STRUCTURE_NAME_ITEM = <STRUCTURE_NAME_ITEM>

IS_KEYINFO = GS_KEYINFO

TABLES

  • T_OUTTAB_HEADER = GT_HEADER_TABLE

T_OUTTAB_HEADER = IT_BSEG

T_OUTTAB_ITEM = GT_ITEM_TABLE

EXCEPTIONS

PROGRAM_ERROR = 1.

  • FORMS ***

FORM FIELDCAT_INIT USING RT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

  • Deviations of group fields to be merged *

  • Initialize group field(s) of header table **

CLEAR LS_FIELDCAT.

ls_fieldcat-col_pos = 1.

LS_FIELDCAT-TABNAME = 'IT_BSEG'.

LS_FIELDCAT-FIELDNAME = 'BLART'.

LS_FIELDCAT-KEY = 'X'. " sets key field

LS_FIELDCAT-SELTEXT_M = 'DOC TYPE'.

LS_FIELDCAT-OUTPUTLEN = 2.

APPEND LS_FIELDCAT TO gt_fieldcat.

CLEAR LS_FIELDCAT.

ls_fieldcat-col_pos = 2.

LS_FIELDCAT-TABNAME = 'IT_BSEG'.

LS_FIELDCAT-FIELDNAME = 'BLDAT'.

LS_FIELDCAT-KEY = 'X'. " sets key field

LS_FIELDCAT-SELTEXT_M = 'DOC DATE'.

LS_FIELDCAT-OUTPUTLEN = 8.

APPEND LS_FIELDCAT TO gt_fieldcat.

CLEAR LS_FIELDCAT.

ls_fieldcat-col_pos = 3.

LS_FIELDCAT-TABNAME = 'IT_BSEG'.

LS_FIELDCAT-FIELDNAME = 'BELNR'.

LS_FIELDCAT-KEY = 'X'. " sets key field

LS_FIELDCAT-SELTEXT_M = 'ACC DOC NO'.

LS_FIELDCAT-OUTPUTLEN = 10.

APPEND LS_FIELDCAT TO gt_fieldcat.

CLEAR LS_FIELDCAT.

ls_fieldcat-col_pos = 4.

LS_FIELDCAT-TABNAME = 'IT_BSEG'.

LS_FIELDCAT-FIELDNAME = 'XBLNR'.

LS_FIELDCAT-KEY = 'X'. " sets key field

LS_FIELDCAT-SELTEXT_M = 'REFERENCE'.

LS_FIELDCAT-OUTPUTLEN = 16.

APPEND LS_FIELDCAT TO gt_fieldcat.

CLEAR LS_FIELDCAT.

ls_fieldcat-col_pos = 5.

LS_FIELDCAT-TABNAME = 'IT_BSEG'.

LS_FIELDCAT-FIELDNAME = 'ZUONR'.

LS_FIELDCAT-KEY = 'X'. " sets key field

LS_FIELDCAT-SELTEXT_M = 'ASSGNMENT NO'.

LS_FIELDCAT-OUTPUTLEN = 19.

APPEND LS_FIELDCAT TO gt_fieldcat.

CLEAR LS_FIELDCAT.

ls_fieldcat-col_pos = 6.

LS_FIELDCAT-TABNAME = 'IT_BSEG'.

LS_FIELDCAT-FIELDNAME = 'DMBTR'.

LS_FIELDCAT-KEY = 'X'. " sets key field

LS_FIELDCAT-SELTEXT_M = 'AMT N LOC CURR'.

LS_FIELDCAT-OUTPUTLEN = 13.

APPEND LS_FIELDCAT TO gt_fieldcat.

  • Initialize keyfield(s) of item table **

CLEAR LS_FIELDCAT.

ls_fieldcat-col_pos = 7.

LS_FIELDCAT-TABNAME = 'GT_ITEM_TABLE'.

LS_FIELDCAT-FIELDNAME = 'AUPOS'.

LS_FIELDCAT-TECH = 'X'. " sets technical field

LS_FIELDCAT-SELTEXT_M = 'LINE ITEM'.

LS_FIELDCAT-OUTPUTLEN = 6.

APPEND LS_FIELDCAT TO gt_fieldcat.

CLEAR LS_FIELDCAT.

ls_fieldcat-col_pos = 8.

LS_FIELDCAT-TABNAME = 'GT_ITEM_TABLE'.

LS_FIELDCAT-FIELDNAME = 'TDLINE'.

LS_FIELDCAT-TECH = 'X'. " sets technical field

LS_FIELDCAT-SELTEXT_M = 'OI NOTES'.

LS_FIELDCAT-OUTPUTLEN = 132.

APPEND LS_FIELDCAT TO gt_fieldcat.

  • Hidden field(s) of tables (header and/or item) **

  • CLEAR LS_FIELDCAT.

    • ls_fieldcat-tabname = '<header/item_table_name>'.

  • LS_FIELDCAT-FIELDNAME = '<GROUP_FIELD_NAME>'.

  • LS_FIELDCAT-NO_OUT = 'X'. "sets hidden field

  • APPEND LS_FIELDCAT TO RT_FIELDCAT.

  • ENDFORM. "fieldcat_init

    ----


    FORM SELECT_DATA.

    data: begin of wa_olino,

    tdname like stxh-tdname,

    tdline like tline-tdline,

    end of wa_olino.

    data: it_olino like wa_olino occurs 0 with header line.

    data: begin of wa_stxh,

    tdname like stxh-tdname,

    end of wa_stxh.

    data: it_stxh like wa_stxh occurs 0 with header line.

    data: begin of wa_lines.

    include structure ztline.

    data: end of wa_lines.

    data: IT_LINES LIKE wa_lines OCCURS 0 WITH HEADER LINE.

    select bukrs kunnr zuonr belnr bldat xblnr blart dmbtr aufnr vbel2

    posn2

    from bsid

    into table it_bseg

    where kunnr in so_wlkun

    and bukrs in so_wlbuk.

    select vbeln aubel aupos vkgrp

    from vbrp

    into table gt_item_table

    for all entries in it_bseg

    where vbeln = it_bseg-belnr.

    sort gt_item_table by aubel aupos.

    loop at gt_item_table into wa_vbrp.

    concatenate wa_vbrp-aubel wa_vbrp-aupos into wa_olino-tdname.

    wa_vbrp-tdname = wa_olino-tdname.

    modify gt_item_table from wa_vbrp.

    append wa_olino to it_olino.

    endloop.

    select tdname from stxh into corresponding fields of table it_stxh

    for all entries in it_olino

    where tdobject = 'VBBP'

    and tdname = it_olino-tdname

    and tdid = '0002'

    and tdspras = 'EN'.

    data: j type i,k_lines type i..

    sort it_stxh by tdname.

    *sort it_output by tdname.

    describe table GT_ITEM_TABLE lines k_lines.

    *loop at it_output into wa_output. "where blart = '1Z'.

    loop at gt_item_table into wa_vbrp.

    loop at it_stxh where tdname = wa_vbrp-tdname.

    read table it_stxh.

    CALL FUNCTION 'ZREAD_TEXT_1'

    EXPORTING

    • CLIENT = SY-MANDT

    ID = '0002'

    LANGUAGE = SY-LANGU

    NAME = IT_STXH-tdname

    OBJECT = 'VBBP'

    • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

    TABLES

    LINES = IT_LINES

    • EXCEPTIONS

    • ID = 1

    • LANGUAGE = 2

    • NAME = 3

    • NOT_FOUND = 4

    • OBJECT = 5

    • REFERENCE_CHECK = 6

    • WRONG_ACCESS_TO_ARCHIVE = 7

    • OTHERS = 8

    .

    *data: I type i.

    if sy-subrc = 0.

    loop at it_lines.

    it_lines-tdname = wa_vbrp-tdname.

    modify it_lines. "from wa_lines.

    endloop.

    loop at it_lines.

    *i = sy-tfill.

    wa_vbrp-tdline = it_lines.

    if sy-tabix = 1.

    modify gt_item_table from wa_vbrp.

    else.

    append wa_vbrp to gt_item_table.

    endif.

    clear it_lines-tdline.

    endloop.

    endif.

    endloop.

    if sy-tabix = k_lines.

    exit.

    endif.

    *

    endloop.

    *

    sort it_olino by tdname.

    ENDFORM. " select_data