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: 

Plz help me

Former Member
0 Kudos
84

Hi,

I 've to display output in alv.Output contains header and line item. So output should be displayed with a header,

under the header i 've to display item data. Again it comes to header under that line items and so on...

I think this can be done using REUSE_ALV_HIER_SEQ_LIST_DISPLAY.but if use this fn module i 've to click plus sign to see the lineitem data.

But by default i want to open this plus sign(diplayed as minus), so that line item will be displayed.

How can we achieve this.

it is Urgent PLZ.

Thanks & Regards,

K P

Message was edited by: K P

1 ACCEPTED SOLUTION

Former Member
0 Kudos
58

Hello KP,

I've looked at some of the demo programs and they don't seem to be having the "Plus" that you're talking about.

Look at the program BALVHD01. Get back if you have questions.

Regards,

anand Mandalika.

4 REPLIES 4

Former Member
0 Kudos
59

Hello KP,

I've looked at some of the demo programs and they don't seem to be having the "Plus" that you're talking about.

Look at the program BALVHD01. Get back if you have questions.

Regards,

anand Mandalika.

Former Member
0 Kudos
58

I don't thinkit will display as you said '+' or '-'. see below example

REPORT BALVHD01 NO STANDARD PAGE HEADING.

  • ALV

TYPE-POOLS: SLIS.

  • DB-Table

TABLES: SCARR, SPFLI.

  • Includes

INCLUDE .

*

CONSTANTS:

GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

GS_LAYOUT TYPE SLIS_LAYOUT_ALV,

GS_KEYINFO TYPE SLIS_KEYINFO_ALV,

GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV,

GT_EVENTS TYPE SLIS_T_EVENT.

  • Data to be displayed

DATA: BEGIN OF GT_SPFLI OCCURS 0.

INCLUDE STRUCTURE SPFLI.

DATA:

BOX,

WERT(4) TYPE P,

LIGHTS.

DATA: END OF GT_SPFLI.

DATA: BEGIN OF GT_SCARR OCCURS 0.

INCLUDE STRUCTURE SCARR.

DATA: BOX,

LIGHTS.

DATA: END OF GT_SCARR.

*

DATA: G_REPID LIKE SY-REPID.

DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

  • Report Selections

SELECT-OPTIONS CARRID FOR SCARR-CARRID.

SELECTION-SCREEN SKIP 1.

  • Parameters

PARAMETERS: P_MAXROW TYPE I DEFAULT 50.

SELECTION-SCREEN SKIP 1.

  • Variante

SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE TEXT-064.

PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.

SELECTION-SCREEN END OF BLOCK 0.

  • Layout

SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-060.

PARAMETERS:

P_ZEBRA AS CHECKBOX DEFAULT ' ',

P_NOCOLH AS CHECKBOX DEFAULT ' ',

P_COLOPT AS CHECKBOX DEFAULT ' ',

P_KEYHOT AS CHECKBOX DEFAULT ' ',

P_NOINPT AS CHECKBOX DEFAULT ' '.

SELECTION-SCREEN END OF BLOCK A.

SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-061.

PARAMETERS:

P_LIGHTN RADIOBUTTON GROUP LIG ,

P_LIGHTH RADIOBUTTON GROUP LIG ,

P_LIGHTI RADIOBUTTON GROUP LIG ,

P_LIGHTC AS CHECKBOX DEFAULT ' '.

SELECTION-SCREEN END OF BLOCK B.

SELECTION-SCREEN BEGIN OF BLOCK C WITH FRAME TITLE TEXT-062.

PARAMETERS:

P_TOTONL AS CHECKBOX DEFAULT ' ',

P_TOTEXT(60),

P_STTEXT(60).

SELECTION-SCREEN END OF BLOCK C.

SELECTION-SCREEN BEGIN OF BLOCK D WITH FRAME TITLE TEXT-063.

PARAMETERS:

CHCKBOXN RADIOBUTTON GROUP BOX ,

CHCKBOXH RADIOBUTTON GROUP BOX ,

CHCKBOXI RADIOBUTTON GROUP BOX ,

  • P_GROUPB AS CHECKBOX DEFAULT ' ',

P_DETPOP AS CHECKBOX DEFAULT 'X',

P_GROUPS AS CHECKBOX DEFAULT ' '.

SELECTION-SCREEN END OF BLOCK D.

DATA: G_BOXNAM TYPE SLIS_FIELDNAME VALUE 'BOX',

P_F2CODE LIKE SY-UCOMM VALUE '&ETA',

P_LIGNAM TYPE SLIS_FIELDNAME VALUE 'LIGHTS',

G_SAVE(1) TYPE C,

G_TABNAME_HEADER TYPE SLIS_TABNAME,

G_TABNAME_ITEM TYPE SLIS_TABNAME,

G_DEFAULT(1) TYPE C,

G_EXIT(1) TYPE C,

GX_VARIANT LIKE DISVARIANT,

G_VARIANT LIKE DISVARIANT.

*----


*

INITIALIZATION.

G_REPID = SY-REPID.

G_TABNAME_HEADER = 'GT_SCARR'.

G_TABNAME_ITEM = 'GT_SPFLI'.

  • define keyinfo

CLEAR GS_KEYINFO.

GS_KEYINFO-HEADER01 = 'CARRID'.

GS_KEYINFO-ITEM01 = 'CARRID'.

GS_KEYINFO-HEADER02 = SPACE.

GS_KEYINFO-ITEM02 = 'CONNID'.

*

PERFORM E01_FIELDCAT_INIT USING GT_FIELDCAT[].

PERFORM E03_EVENTTAB_BUILD USING GT_EVENTS[].

PERFORM E04_COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].

PERFORM E07_SP_GROUP_BUILD USING GT_SP_GROUP[].

  • Schalter Varianten benutzerspezifisch/allgemein speicherbar setzen

  • Set Options: save variants userspecific or general

G_SAVE = 'A'.

PERFORM VARIANT_INIT.

  • Get default variant

GX_VARIANT = G_VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

I_SAVE = G_SAVE

CHANGING

CS_VARIANT = GX_VARIANT

EXCEPTIONS

NOT_FOUND = 2.

IF SY-SUBRC = 0.

P_VARI = GX_VARIANT-VARIANT.

ENDIF.

  • Process on value request

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.

PERFORM F4_FOR_VARIANT.

  • PAI

AT SELECTION-SCREEN.

PERFORM PAI_OF_SELECTION_SCREEN.

START-OF-SELECTION.

PERFORM SELECTION.

END-OF-SELECTION.

PERFORM E05_LAYOUT_BUILD USING GS_LAYOUT. "wg. Parameters

  • Call ABAP/4 List Viewer

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

IS_LAYOUT = GS_LAYOUT

IT_FIELDCAT = GT_FIELDCAT[]

  • IT_EXCLUDING =

IT_SPECIAL_GROUPS = GT_SP_GROUP[]

  • 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 = g_default

I_SAVE = G_SAVE

IS_VARIANT = G_VARIANT

IT_EVENTS = GT_EVENTS[]

  • IT_EVENT_EXIT =

I_TABNAME_HEADER = G_TABNAME_HEADER

I_TABNAME_ITEM = G_TABNAME_ITEM

IS_KEYINFO = GS_KEYINFO

  • IS_PRINT =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

TABLES

T_OUTTAB_HEADER = GT_SCARR

T_OUTTAB_ITEM = GT_SPFLI.

*----


*

  • FORM E01_FIELDCAT_INIT *

*----


*

  • ........ *

*----


*

  • --> E01_LT_FIELDCAT *

*----


*

FORM E01_FIELDCAT_INIT USING E01_LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

*

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'DISTANCE'.

LS_FIELDCAT-TABNAME = G_TABNAME_ITEM.

LS_FIELDCAT-NO_OUT = 'X'.

LS_FIELDCAT-NO_SUM = 'X'.

LS_FIELDCAT-SP_GROUP = 'A'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

*

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'DISTID'.

LS_FIELDCAT-TABNAME = G_TABNAME_ITEM.

LS_FIELDCAT-NO_OUT = 'X'.

LS_FIELDCAT-NO_SUM = 'X'.

LS_FIELDCAT-SP_GROUP = 'A'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

*

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'CARRID'.

LS_FIELDCAT-TABNAME = G_TABNAME_ITEM.

LS_FIELDCAT-TECH = 'X'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

*

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'FLTYPE'.

LS_FIELDCAT-TABNAME = G_TABNAME_ITEM.

LS_FIELDCAT-NO_OUT = 'X'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

*

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

  • I_PROGRAM_NAME =

I_INTERNAL_TABNAME = G_TABNAME_HEADER

I_STRUCTURE_NAME = 'SCARR'

  • I_CLIENT_NEVER_DISPLAY = 'X'

CHANGING

CT_FIELDCAT = E01_LT_FIELDCAT[].

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

  • I_PROGRAM_NAME =

I_INTERNAL_TABNAME = G_TABNAME_ITEM

I_STRUCTURE_NAME = 'SPFLI'

  • I_CLIENT_NEVER_DISPLAY = 'X'

CHANGING

CT_FIELDCAT = E01_LT_FIELDCAT[].

  • Nachbessern!!!

  • CLEAR LS_FIELDCAT.

  • LS_FIELDCAT-FIELDNAME = 'CARRID'.

  • LS_FIELDCAT-TABNAME = G_TABNAME_HEADER.

  • LS_FIELDCAT-REF_FIELDNAME = 'CARRID'.

  • LS_FIELDCAT-REF_TABNAME = 'SCARR'.

  • LS_FIELDCAT-KEY = 'X'.

  • APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • geht am Anfang nicht !!!!

CLEAR LS_FIELDCAT.

LS_FIELDCAT-COL_POS = 99.

LS_FIELDCAT-FIELDNAME = 'WERT'.

LS_FIELDCAT-TABNAME = G_TABNAME_ITEM.

LS_FIELDCAT-REPTEXT_DDIC = 'Wert'(070).

LS_FIELDCAT-OUTPUTLEN = 4.

LS_FIELDCAT-DATATYPE = 'CURR'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

ENDFORM.

*----


*

  • FORM E02_DATA_ADD *

*----


*

  • ........ *

*----


*

FORM E02_DATA_ADD TABLES E02_LT_SPFLI STRUCTURE GT_SPFLI

E02_LT_SCARR STRUCTURE GT_SCARR.

LOOP AT E02_LT_SPFLI.

IF SY-TABIX > 10.

E02_LT_SPFLI-BOX = 'X'.

E02_LT_SPFLI-LIGHTS = '3'.

ELSE.

IF SY-TABIX = 1.

E02_LT_SPFLI-LIGHTS = '2'.

ELSE.

E02_LT_SPFLI-LIGHTS = '1'.

ENDIF.

ENDIF.

E02_LT_SPFLI-WERT = SY-TABIX MOD 5.

MODIFY E02_LT_SPFLI.

ENDLOOP.

*

LOOP AT E02_LT_SCARR.

IF SY-TABIX > 10.

E02_LT_SCARR-BOX = 'X'.

E02_LT_SCARR-LIGHTS = '3'.

ELSE.

IF SY-TABIX = 1.

E02_LT_SCARR-LIGHTS = '2'.

ELSE.

E02_LT_SCARR-LIGHTS = '1'.

ENDIF.

ENDIF.

MODIFY E02_LT_SCARR.

ENDLOOP.

ENDFORM.

*----


*

  • FORM E03_EVENTTAB_BUILD *

*----


*

  • ........ *

*----


*

  • --> E03_LT_EVENTS *

*----


*

FORM E03_EVENTTAB_BUILD USING E03_LT_EVENTS TYPE SLIS_T_EVENT.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

*

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = E03_LT_EVENTS.

READ TABLE E03_LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

APPEND LS_EVENT TO E03_LT_EVENTS.

ENDIF.

ENDFORM.

*----


*

  • FORM E04_COMMENT_BUILD *

*----


*

  • ........ *

*----


*

  • --> E04_LT_TOP_OF_PAGE *

*----


*

FORM E04_COMMENT_BUILD USING E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

DATA: LS_LINE TYPE SLIS_LISTHEADER.

*

  • Listenüberschrift: Typ H

CLEAR LS_LINE.

LS_LINE-TYP = 'H'.

  • LS_LINE-KEY: not used for this type

LS_LINE-INFO = TEXT-001.

APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.

  • Kopfinfo: Typ S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = TEXT-050.

LS_LINE-INFO = TEXT-010.

APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.

LS_LINE-KEY = TEXT-051.

APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.

  • Aktionsinfo: Typ A

CLEAR LS_LINE.

LS_LINE-TYP = 'A'.

  • LS_LINE-KEY: not used for this type

LS_LINE-INFO = TEXT-002.

APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.

ENDFORM.

*----


*

  • FORM E05_LAYOUT_BUILD *

*----


*

  • ........ *

*----


*

  • <-> E05_LS_LAYOUT *

*----


*

FORM E05_LAYOUT_BUILD USING E05_LS_LAYOUT TYPE SLIS_LAYOUT_ALV.

IF P_LIGHTI = 'X'.

E05_LS_LAYOUT-LIGHTS_FIELDNAME = P_LIGNAM.

E05_LS_LAYOUT-LIGHTS_TABNAME = G_TABNAME_ITEM.

E05_LS_LAYOUT-LIGHTS_CONDENSE = P_LIGHTC.

ENDIF.

IF P_LIGHTH = 'X'.

E05_LS_LAYOUT-LIGHTS_FIELDNAME = P_LIGNAM.

E05_LS_LAYOUT-LIGHTS_TABNAME = G_TABNAME_HEADER.

E05_LS_LAYOUT-LIGHTS_CONDENSE = P_LIGHTC.

ENDIF.

IF P_LIGHTN = 'X'.

CLEAR E05_LS_LAYOUT-LIGHTS_FIELDNAME.

CLEAR E05_LS_LAYOUT-LIGHTS_TABNAME.

CLEAR E05_LS_LAYOUT-LIGHTS_CONDENSE.

ENDIF.

IF CHCKBOXN = 'X'.

E05_LS_LAYOUT-BOX_FIELDNAME = SPACE.

E05_LS_LAYOUT-BOX_TABNAME = SPACE.

ENDIF.

IF CHCKBOXH = 'X'.

E05_LS_LAYOUT-BOX_FIELDNAME = G_BOXNAM.

E05_LS_LAYOUT-BOX_TABNAME = G_TABNAME_HEADER.

ENDIF.

IF CHCKBOXI = 'X'.

E05_LS_LAYOUT-BOX_FIELDNAME = G_BOXNAM.

E05_LS_LAYOUT-BOX_TABNAME = G_TABNAME_ITEM.

ENDIF.

E05_LS_LAYOUT-HEADER_TEXT = TEXT-071.

E05_LS_LAYOUT-ITEM_TEXT = TEXT-072.

E05_LS_LAYOUT-DEFAULT_ITEM = 'X'.

E05_LS_LAYOUT-F2CODE = P_F2CODE.

E05_LS_LAYOUT-ZEBRA = P_ZEBRA.

E05_LS_LAYOUT-COLWIDTH_OPTIMIZE = P_COLOPT.

E05_LS_LAYOUT-NO_INPUT = P_NOINPT.

E05_LS_LAYOUT-NO_COLHEAD = P_NOCOLH.

E05_LS_LAYOUT-TOTALS_TEXT = P_TOTEXT.

E05_LS_LAYOUT-SUBTOTALS_TEXT = P_STTEXT.

E05_LS_LAYOUT-TOTALS_ONLY = P_TOTONL.

E05_LS_LAYOUT-KEY_HOTSPOT = P_KEYHOT.

E05_LS_LAYOUT-DETAIL_POPUP = P_DETPOP.

E05_LS_LAYOUT-GROUP_CHANGE_EDIT = P_GROUPS.

  • E05_LS_LAYOUT-GROUP_BUTTONS = P_GROUPB.

E05_LS_LAYOUT-GROUP_BUTTONS = SPACE.

ENDFORM.

*----


*

  • FORM E07_SP_GROUP_BUILD *

*----


*

  • ........ *

*----


*

  • --> E07_LT_SP_GROUP *

*----


*

FORM E07_SP_GROUP_BUILD USING E07_LT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV.

DATA: LS_SP_GROUP TYPE SLIS_SP_GROUP_ALV.

*

CLEAR LS_SP_GROUP.

LS_SP_GROUP-SP_GROUP = 'A'.

LS_SP_GROUP-TEXT = TEXT-005.

APPEND LS_SP_GROUP TO E07_LT_SP_GROUP.

ENDFORM.

*----


*

  • FORM SELECTION *

*----


*

  • ........ *

*----


*

FORM SELECTION.

SELECT * FROM SCARR INTO CORRESPONDING FIELDS OF TABLE GT_SCARR

WHERE CARRID IN CARRID.

SELECT * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE GT_SPFLI

UP TO P_MAXROW ROWS

WHERE CARRID IN CARRID.

LOOP AT GT_SCARR.

READ TABLE GT_SPFLI WITH KEY CARRID = GT_SCARR-CARRID.

IF SY-SUBRC NE 0.

DELETE GT_SCARR.

ENDIF.

ENDLOOP.

*

PERFORM E02_DATA_ADD TABLES GT_SPFLI GT_SCARR.

ENDFORM.

*----


*

  • FORM TOP_OF_PAGE *

*----


*

  • ........ *

*----


*

FORM TOP_OF_PAGE.

*

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

ENDFORM.

*----


*

  • FORM F4_FOR_VARIANT *

*----


*

  • ........ *

*----


*

FORM F4_FOR_VARIANT.

*

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

IS_VARIANT = G_VARIANT

I_SAVE = G_SAVE

I_TABNAME_HEADER = G_TABNAME_HEADER

I_TABNAME_ITEM = G_TABNAME_ITEM

  • it_default_fieldcat =

IMPORTING

E_EXIT = G_EXIT

ES_VARIANT = GX_VARIANT

EXCEPTIONS

NOT_FOUND = 2.

IF SY-SUBRC = 2.

MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

IF G_EXIT = SPACE.

P_VARI = GX_VARIANT-VARIANT.

ENDIF.

ENDIF.

ENDFORM.

*&----


*

*& Form PAI_OF_SELECTION_SCREEN

*&----


*

  • text

*----


*

FORM PAI_OF_SELECTION_SCREEN.

*

IF NOT P_VARI IS INITIAL.

MOVE G_VARIANT TO GX_VARIANT.

MOVE P_VARI TO GX_VARIANT-VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

I_SAVE = G_SAVE

CHANGING

CS_VARIANT = GX_VARIANT.

G_VARIANT = GX_VARIANT.

ELSE.

PERFORM VARIANT_INIT.

ENDIF.

ENDFORM. " PAI_OF_SELECTION_SCREEN

*&----


*

*& Form VARIANT_INIT

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM VARIANT_INIT.

*

CLEAR G_VARIANT.

G_VARIANT-REPORT = G_REPID.

ENDFORM. " VARIANT_INIT

0 Kudos
58

Hello NVVS,

What's the point in pasting the entire code for a standard program in the forum post? You could have just mentioned the name of the program.

By the way, I had already suggested the name of the program. The same one which you copied the code for...

Regards,

Anand Mandalika.

0 Kudos
58

Hi all,

Thanq very much for your prompt replies. I think these information would solve my problem.

Thanks & Regards,

Kesava.