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: 

User Command not working with 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

Former Member
0 Kudos
978

Hello ABAP gurus,

I am using 'REUSE_ALV_HIERSEQ_LIST_DISPLAY' for ALV

for hierarchical lists. The call looks like this

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = GV_REPID

I_CALLBACK_USER_COMMAND = SLIS_EV_USER_COMMAND

I_CALLBACK_PF_STATUS_SET = SLIS_EV_PF_STATUS_SET

IT_FIELDCAT = GT_SLIS_FCAT

I_SAVE = GC_SAVE

IT_EVENTS = GT_EVENTS

IS_LAYOUT = GS_LAYOUT

I_TABNAME_HEADER = GC_TABNAME_HEADER1

I_TABNAME_ITEM = GC_TABNAME_DETAIL1

I_STRUCTURE_NAME_HEADER = GC_STRUCTURE_HEADER

I_STRUCTURE_NAME_ITEM = GC_STRUCTURE_DETAIL

IS_KEYINFO = GS_KEYINFO

TABLES

T_OUTTAB_HEADER = GT_OUTPUT_HEADER1

T_OUTTAB_ITEM = GT_OUTPUT_DETAIL1

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

I have populated SLIS_EV_USER_COMMAND with the form name on user command and GT_EVENTS with the value 'USER_COMMAND' . Still on clicking any row in the ALV list am getting the message 'Choose a valid function'. Can anybody let me know if I am missing something?. Any pointers would be highly appreciated.

TIA

sharath

9 REPLIES 9

jayanthi_jayaraman
Active Contributor
0 Kudos
129

Hi,

Check this link which also discusses similar thing.

If suppose you are clicking in some other place other than the line,it will show like that.

Check this for sample coding.

http://www.sap-img.com/abap/how-to-use-alv-for-hierarchical-lists.htm

This is part of the sample coding.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = LV_REPID

I_CALLBACK_PF_STATUS_SET = 'SET_STATUS'

I_SAVE = C_X

IS_VARIANT = W_VARIANT

IT_EVENTS = I_EVENTS[]

IS_LAYOUT = W_LAYOUT

I_TABNAME_HEADER = 'I_OUTPUT'

I_TABNAME_ITEM = 'I_OUTPUT1'

IT_FIELDCAT = I_FIELDCAT[]

IS_KEYINFO = W_KEYINFO

I_BYPASSING_BUFFER = C_X

TABLES

T_OUTTAB_HEADER = I_OUTPUT

T_OUTTAB_ITEM = I_OUTPUT1

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE i278. "Error in ALV report display

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. " f9003_alv_hier_list

&----


*& Form USER_COMMAND

&----


  • Processing the ALV User_Command Event

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

DATA: LV_TABNAME LIKE RS_SELFIELD-TABNAME ,

LV_DOCNUM LIKE EDIDC-DOCNUM,

LV_CUSTPARTN LIKE E1EDKA1-PARTN .

R_UCOMM = W_LAYOUT-F2CODE.

CHECK R_UCOMM EQ C_DBLCLK.

CASE RS_SELFIELD-FIELDNAME.

WHEN C_CUST_PARTN.

READ TABLE I_OUTPUT INTO W_OUTPUT INDEX RS_SELFIELD-TABINDEX.

LV_CUSTPARTN = W_OUTPUT-CUST_PARTN.

CHECK SY-SUBRC EQ 0.

IF NOT LV_CUSTPARTN IS INITIAL.

  • call transaction XD03

SET PARAMETER ID 'KUN' FIELD LV_CUSTPARTN.

CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

ENDFORM. " alv_user_command

Former Member
0 Kudos
129

Hi,

Check this

http://sap.ittoolbox.com/groups/groups.asp?v=SAP-R3-DEV&i=214437

Check this link

http://www.sap-img.com/abap/how-to-use-alv-for-hierarchical-lists.htm

http://www.ecediltd.com/la/sap-r3-dev@openitx.com/0376.html

http://www.geocities.com/mpioud/Z_ALV_HIERSEQ_LIST.html

Also do a search in this forum u will get more info.

Thanks & Regards,

Judith.

Message was edited by: Judith Jessie Selvi

Message was edited by: Judith Jessie Selvi

Former Member
0 Kudos
129

Thanks for those links, but those weren't of much help.

When you double click on a 'detail line' in ALV list it should trigger the user_command event with fcode '&IC1'. But when you double click on a header line it should say 'Choose a valid function'. So I feel there must be some property to be set in the structure field catalog/layout which makes 'detail line' double click intensive(?).

I have set HOTSPOT on for the fields in catalog but that just makes them respond to single click.

Also tried with properties F2CODE n KEY_HOTSPOT in the GS_LAYOUT but still am getting 'Choose a valid function' and the event is not triggered.

As per that pdf-->

In ALV Grid Control this is done by some thing like this

"handle_double_click FOR EVENT double_click OF cl_gui_alv_grid IMPORTING e_row e_column

You do nothing additional to make a field double-click intensive; that is you need not set some option in the field catalog."

But ALV Grid Control does not support hierarchical lists. There must be something I am missing. What could this be?

0 Kudos
129

Hi,

Just try removing the hotspot and check the sy-ucomm.

I don't think these things as necessary.

I_CALLBACK_USER_COMMAND = SLIS_EV_USER_COMMAND

I_STRUCTURE_NAME_HEADER = GC_STRUCTURE_HEADER

I_STRUCTURE_NAME_ITEM = GC_STRUCTURE_DETAIL

Check it.Because I have also used Hierarcial ALV without these.It is working fine.

You can see it in my coding sample.

0 Kudos
129

Hi,

Have u checked this part

FORM user_command USING i_ucomm LIKE sy-ucomm

is_selfield TYPE slis_selfield. "#EC CALLED

CASE i_ucomm.

WHEN '&IC1'. " Pick

CASE is_selfield-tabname.

WHEN 'GT_VBAP'.

WHEN 'GT_VBAK'.

READ TABLE gt_vbak INDEX is_selfield-tabindex.

IF sy-subrc EQ 0.

  • Sales order number

SET PARAMETER ID 'AUN' FIELD gt_vbak-vbeln.

  • Display Sales Order

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

ENDCASE.

ENDFORM.

0 Kudos
129

Hi,

In your At_user_command form, what is the value for g_fcode?

Former Member
0 Kudos
129

Without HOTSPOT also, on double click I get the same message 'Choose a valid function'. Its still insensitive to any user command.

I_CALLBACK_USER_COMMAND is necessary because I want the form to be called on USER_COMMAND which is passed in the field SLIS_EV_USER_COMMAND.

0 Kudos
129

Hi,

Could you paste the entire code.

Former Member
0 Kudos
129

I have pasted all the ALV relevant part of the program.

  • DATA DECLARATION

TYPE-POOLS: SLIS.

CONSTANTS :

GC_SAVE TYPE C VALUE 'X', "Save option for variant

GC_HEAD TYPE SLIS_LISTHEADER-TYP VALUE 'A',

GC_X TYPE C VALUE 'X',

GC_Y TYPE C VALUE 'Y',

GC_PF_STATUS TYPE SLIS_FORMNAME " PF Status

VALUE 'BEN_ALV'.

CONSTANTS:

GC_STRUCTURE_HEADER LIKE DD02L-TABNAME VALUE 'RPLBEN07_ALV',

GC_STRUCTURE_DETAIL LIKE DD02L-TABNAME VALUE 'RPLBEN07_ALV1',

GC_TABNAME_HEADER1 TYPE SLIS_TABNAME

VALUE 'GT_OUTPUT_HEADER1',

GC_TABNAME_DETAIL1 TYPE SLIS_TABNAME

VALUE 'GT_OUTPUT_DETAIL1',

GC_TABNAME_HEADER2 TYPE SLIS_TABNAME

VALUE 'GT_OUTPUT_HEADER2',

GC_TABNAME_DETAIL2 TYPE SLIS_TABNAME

VALUE 'GT_OUTPUT_DETAIL2'.

DATA : GV_TAB_HEADER TYPE SLIS_TABNAME.

DATA : GV_TAB_DETAIL TYPE SLIS_TABNAME.

DATA :

GV_REPID LIKE SY-REPID.

DATA: GS_OUTPUT_HEADER TYPE RPLBEN07_ALV ."Structure for Header Table

DATA : BEGIN OF GS_OUTPUT_DETAIL.

INCLUDE STRUCTURE RPLBEN07_ALV1 ."Structure for Detail Table

DATA : INFTY TYPE P0167-INFTY,

SUBTY TYPE P0167-SUBTY,

OBJPS TYPE P0167-OBJPS,

END OF GS_OUTPUT_DETAIL.

      • Global Internal Table Declaration

  • Internal Table for Header Data

DATA :

GT_OUTPUT_HEADER1 TYPE STANDARD TABLE OF RPLBEN07_ALV,

GT_OUTPUT_HEADER2 TYPE STANDARD TABLE OF RPLBEN07_ALV,

  • Internal Table for Detail Data

GT_OUTPUT_DETAIL1 LIKE TABLE OF GS_OUTPUT_DETAIL,

GT_OUTPUT_DETAIL2 LIKE TABLE OF GS_OUTPUT_DETAIL.

DATA : GT_FIELDCAT_HIERSEQ_LIST TYPE SLIS_T_FIELDCAT_ALV, "Field Catalog

GT_EVENTS TYPE SLIS_T_EVENT, " Events Table

GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,

GS_LAYOUT TYPE SLIS_LAYOUT_ALV,

GS_KEYINFO TYPE SLIS_KEYINFO_ALV."Key Field

*"Callback

  • declaring structure

DATA: BEGIN OF GS_SECOND_TOP.

INCLUDE TYPE SLIS_LISTHEADER.

DATA COUNT_TOP TYPE I.

DATA: END OF GS_SECOND_TOP.

  • declaring a internal table

DATA GT_TOP LIKE TABLE OF GS_SECOND_TOP.

*"Variants

DATA : GS_VARIANT TYPE DISVARIANT,

GS_LINE TYPE SLIS_LISTHEADER,

G_FCODE LIKE SY-UCOMM.

DATA : GT_SLIS_FCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA : GS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA : GV_COUNTER TYPE I.

DATA : GV_TEMP_1 TYPE I.

GV_TEMP_1 = 1.

FIELD-SYMBOLS <FS> TYPE SLIS_FIELDCAT_ALV.

&----


  • Starts ALV coding

  • adding new subroutines required for alv display

&----


*& Form VARIANT_INIT_ALV

&----


  • This subroutine initilizes variant.

----


  • <-> XS_VARIANT variant

----


  • Used global variables:

  • gc_variant_handle handle for variant

*----


FORM VARIANT_INIT_ALV CHANGING XS_VARIANT TYPE DISVARIANT.

MOVE SY-REPID TO GV_REPID.

  • report name.

IF XS_VARIANT-REPORT IS INITIAL.

MOVE GV_REPID TO XS_VARIANT-REPORT.

ENDIF.

ENDFORM. " VARIANT_INIT_ALV

&----


*& Form LAYOUT_RESERVATION_GET

&----


  • This form defines layout for ALV Grid

----


  • <->XS_LAYOUT layout

----


FORM LAYOUT_RESERVATION_GET CHANGING XS_LAYOUT TYPE SLIS_LAYOUT_ALV.

XS_LAYOUT-MIN_LINESIZE = '200'.

ENDFORM. " LAYOUT_INIT_ALV

&----


*& Form EVENTTAB_BUILD_ALV

&----


  • This subroutine uses the function module REUSE_ALV_EVENTS_GET. This

  • function module gives the events ( in the event table ) that can be

  • used in the ALV scenario. The event table is then modified as per the

  • required events. This modified event table will then be passed to the

  • grid display function module.

----


  • -->XT_EVENTS TYPE slis_t_event

----


FORM EVENTTAB_BUILD_ALV USING XT_EVENTS TYPE SLIS_T_EVENT.

DATA : LS_EVENT TYPE SLIS_ALV_EVENT.

DATA : LV_TABIX LIKE SY-TABIX.

  • getting all the evenets that may happen during grid display

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = XT_EVENTS.

  • To use the TOP-OF-PAGE event

CLEAR LS_EVENT.

READ TABLE XT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE SLIS_EV_TOP_OF_PAGE TO LS_EVENT-FORM.

MODIFY XT_EVENTS FROM LS_EVENT TRANSPORTING FORM

WHERE NAME = SLIS_EV_TOP_OF_PAGE.

ENDIF.

*Pass the subroutine name to the END-OF-LIST event when the end of list

*is triggered

CLEAR LS_EVENT.

READ TABLE XT_EVENTS WITH KEY NAME = SLIS_EV_END_OF_LIST INTO LS_EVENT

.

IF SY-SUBRC = 0.

MOVE SLIS_EV_END_OF_LIST TO LS_EVENT-FORM.

MODIFY XT_EVENTS FROM LS_EVENT TRANSPORTING FORM

WHERE NAME = SLIS_EV_END_OF_LIST.

ENDIF.

  • To use the gui status event

CLEAR LS_EVENT.

READ TABLE XT_EVENTS WITH KEY NAME = SLIS_EV_PF_STATUS_SET INTO

LS_EVENT.

MOVE : SY-TABIX TO LV_TABIX.

IF SY-SUBRC = 0.

MOVE SLIS_EV_PF_STATUS_SET TO LS_EVENT-FORM.

MODIFY XT_EVENTS FROM LS_EVENT TRANSPORTING FORM

WHERE NAME = SLIS_EV_PF_STATUS_SET.

ENDIF.

  • To use the user command event

CLEAR LS_EVENT.

READ TABLE XT_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND INTO

LS_EVENT.

IF SY-SUBRC = 0.

MOVE SLIS_EV_USER_COMMAND TO LS_EVENT-FORM.

MODIFY XT_EVENTS FROM LS_EVENT TRANSPORTING FORM

WHERE NAME = SLIS_EV_USER_COMMAND.

ENDIF.

ENDFORM. " EVENTTAB_BUILD_ALV

&----


*& Form OUTPUT_VARIANT_F4_ALV

&----


  • Provide F4 help for the ALV Layout parameter field

*----


FORM OUTPUT_VARIANT_F4_ALV .

MOVE SY-REPID TO GV_REPID.

  • move the report name

MOVE : GV_REPID TO GS_VARIANT-REPORT.

  • F4 Help.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

IS_VARIANT = GS_VARIANT

I_SAVE = GC_SAVE

IMPORTING

ES_VARIANT = GS_VARIANT

EXCEPTIONS

NOT_FOUND = 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.

ELSE.

MOVE GS_VARIANT-VARIANT TO P_VARI.

ENDIF.

ENDFORM. " OUTPUT_VARIANT_F4_ALV

&----


*& Form LAYOUT_VARIANT_CHECK_ALV

&----


  • Subroutine to check the variant entered by the user

*----


  • <-> XS_VARIANT variant

----


  • Used global variables:

  • gc_variant_handle handle for variant

  • p_vari variant

*----


FORM LAYOUT_VARIANT_CHECK_ALV CHANGING XS_VARIANT TYPE DISVARIANT.

MOVE SY-REPID TO GV_REPID.

MOVE XS_VARIANT TO GS_VARIANT.

  • move the report name

MOVE GV_REPID TO GS_VARIANT-REPORT.

  • move the handle name

MOVE P_VARI TO GS_VARIANT-VARIANT.

  • check for variant existence.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

I_SAVE = GC_SAVE

CHANGING

CS_VARIANT = GS_VARIANT

EXCEPTIONS

WRONG_INPUT = 1

NOT_FOUND = 2

PROGRAM_ERROR = 3

OTHERS = 4.

  • HANDLING THE EXCEPTIONS FOR VARIANT EXISTENCE

CASE SY-SUBRC.

WHEN 0.

XS_VARIANT = GS_VARIANT.

WHEN 2.

  • Layout is not found!

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER '017'

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

WHEN OTHERS.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

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

ENDCASE.

ENDFORM. " LAYOUT_VARIANT_CHECK_ALV

&----


*& Form TOP_OF_PAGE

&----


  • This subroutine is used to display the header information onto

  • the screen

----


FORM TOP_OF_PAGE.

REFRESH GT_LIST_TOP_OF_PAGE.

  • The internal table with the data required to be displayed in the

  • header is passed to the function module.

IF GV_TEMP_1 = 1.

ADD 1 TO GV_TEMP_1.

LOOP AT GT_TOP INTO GS_SECOND_TOP WHERE COUNT_TOP = 1.

MOVE-CORRESPONDING GS_SECOND_TOP TO GS_LINE.

APPEND GS_LINE TO GT_LIST_TOP_OF_PAGE.

ENDLOOP.

ELSE.

LOOP AT GT_TOP INTO GS_SECOND_TOP WHERE COUNT_TOP = 2.

MOVE-CORRESPONDING GS_SECOND_TOP TO GS_LINE.

APPEND GS_LINE TO GT_LIST_TOP_OF_PAGE.

ENDLOOP.

ENDIF.

PERFORM WRITE_EVALUATION_PERIOD CHANGING GT_LIST_TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

SET BLANK LINES OFF.

ENDFORM. "TOP_OF_PAGE

&----


*& Form SET_PF_STATUS

&----


  • This subroutine is used to set the standard alv status.

----


FORM PF_STATUS_SET USING XT_EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS GC_PF_STATUS EXCLUDING XT_EXTAB. "#EC *

ENDFORM. "set_pf_status

&----


*& Form AT_USER_COMMAND

&----


  • This subroutine handles the user command.

----


  • --> UCOMM *

  • --> SELFIELD *

----


FORM USER_COMMAND USING UCOMM TYPE SY-UCOMM

SELFIELD TYPE SLIS_SELFIELD .

G_FCODE = UCOMM.

DATA : LV_TABNAME TYPE SLIS_TABNAME.

MOVE SELFIELD-TABNAME TO LV_TABNAME.

IF SELFIELD-TABNAME = 'GT_OUTPUT_DETAIL1'.

READ TABLE GT_OUTPUT_DETAIL1 INTO GS_OUTPUT_DETAIL

INDEX SELFIELD-TABINDEX.

ELSEIF SELFIELD-TABNAME = 'GT_OUTPUT_DETAIL2'.

READ TABLE GT_OUTPUT_DETAIL2 INTO GS_OUTPUT_DETAIL

INDEX SELFIELD-TABINDEX.

ENDIF.

CASE G_FCODE.

WHEN '&IC1' .

IF NOT GS_OUTPUT_DETAIL-PERSNO IS INITIAL. " Valid line selected

CALL FUNCTION 'HR_BEN_CALL_INFOTYPE'

EXPORTING

PERNR = GS_OUTPUT_DETAIL-PERSNO

INFTY = GS_OUTPUT_DETAIL-INFTY

SUBTY = SPACE

OBJPS = SPACE

BEGDA = GS_OUTPUT_DETAIL-BEGDA

ENDDA = GS_OUTPUT_DETAIL-ENDDA

OPERATION = 'DIS'

REACTION = NO_MSG

IMPORTING

SUBRC = SUBRC

TABLES

ERROR_TABLE = ERROR_TABLE.

CHECK SUBRC EQ 0.

ELSE.

MESSAGE W519(00).

ENDIF.

ENDCASE.

ENDFORM. "at_user_command

&----


*& Form OUTPUT_GRID_ALV

&----


  • This subroutine uses the function module REUSE_ALV_GRID_DISPLAY

  • to display the alv grid output on the basis of the parameters

  • passed to them.

----


FORM OUTPUT_GRID_ALV .

DATA : LV_KEY1(8) TYPE C VALUE 'PROV_BEN',

LV_KEY2(8) TYPE C VALUE 'PLAN_BEN'.

CLEAR: GS_KEYINFO.

GS_KEYINFO-HEADER01 = LV_KEY1.

GS_KEYINFO-HEADER02 = LV_KEY2.

GS_KEYINFO-ITEM01 = LV_KEY1.

GS_KEYINFO-ITEM02 = LV_KEY2.

MOVE SY-REPID TO GV_REPID.

MOVE GC_TABNAME_HEADER1 TO GV_TAB_HEADER.

MOVE GC_TABNAME_DETAIL1 TO GV_TAB_DETAIL.

  • Initializing the ALV Variant parameter with the default variant.

PERFORM VARIANT_INIT_ALV CHANGING GS_VARIANT.

  • Setting layout of ALV grid

PERFORM LAYOUT_RESERVATION_GET CHANGING GS_LAYOUT.

  • Fill the events table with the required events

PERFORM EVENTTAB_BUILD_ALV CHANGING GT_EVENTS[].

  • build the field catalog for the ALV.

PERFORM FIELDCAT_BUILD_ALV USING GV_TAB_HEADER GV_TAB_DETAIL

CHANGING GT_SLIS_FCAT.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = GV_REPID

I_CALLBACK_USER_COMMAND = SLIS_EV_USER_COMMAND

I_CALLBACK_PF_STATUS_SET = SLIS_EV_PF_STATUS_SET

IT_FIELDCAT = GT_SLIS_FCAT

I_SAVE = GC_SAVE

IT_EVENTS = GT_EVENTS

IS_LAYOUT = GS_LAYOUT

I_TABNAME_HEADER = GC_TABNAME_HEADER1

I_TABNAME_ITEM = GC_TABNAME_DETAIL1

I_STRUCTURE_NAME_HEADER = GC_STRUCTURE_HEADER

I_STRUCTURE_NAME_ITEM = GC_STRUCTURE_DETAIL

IS_KEYINFO = GS_KEYINFO

TABLES

T_OUTTAB_HEADER = GT_OUTPUT_HEADER1

T_OUTTAB_ITEM = GT_OUTPUT_DETAIL1

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

&----


*& Form FIELDCAT_BUILD_ALV

&----


  • This subroutine uses the function module *

  • REUSE_ALV_FIELDCATALOG_MERGE to add Field catalog to the ALV grid

*----


  • <--XT_FCAT

----


FORM FIELDCAT_BUILD_ALV USING XV_TAB_HEADER TYPE SLIS_TABNAME

XV_TAB_DETAIL TYPE SLIS_TABNAME

CHANGING XT_FCAT TYPE SLIS_T_FIELDCAT_ALV.

*get header

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = GV_REPID

I_INTERNAL_TABNAME = XV_TAB_HEADER

I_STRUCTURE_NAME = GC_STRUCTURE_HEADER

I_BYPASSING_BUFFER = GC_X

CHANGING

CT_FIELDCAT = XT_FCAT

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.

    • get details

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = GV_REPID

I_INTERNAL_TABNAME = XV_TAB_DETAIL

I_STRUCTURE_NAME = GC_STRUCTURE_DETAIL

I_BYPASSING_BUFFER = GC_X

CHANGING

CT_FIELDCAT = XT_FCAT

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.

**here we are assigning the attributes to field catalogue

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'PROV_BEN'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 1.

<FS>-OUTPUTLEN = 8.

<FS>-LZERO = 'X'.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-T06.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'PROV_TXT'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 2.

<FS>-OUTPUTLEN = 27.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-T03.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'PLAN_BEN'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 3.

<FS>-OUTPUTLEN = 8.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-T07.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'PLAN_TXT'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 4.

<FS>-OUTPUTLEN = 30.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-T05.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'RCOUNT'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 5.

<FS>-OUTPUTLEN = 4.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-F01.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'PROV_BEN'

TABNAME = XV_TAB_DETAIL

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-TECH = GC_X.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'PLAN_BEN'

TABNAME = XV_TAB_DETAIL

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-TECH = GC_X.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'NAME'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 6.

<FS>-OUTPUTLEN = 32.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-H01.

<FS>-HOTSPOT = 'X'.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'PERSNO'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 7.

<FS>-OUTPUTLEN = 10.

<FS>-LZERO = 'X'.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-H14.

<FS>-HOTSPOT = 'X'.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'BEGDA'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 8.

<FS>-OUTPUTLEN = 10.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-H17.

<FS>-HOTSPOT = 'X'.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'ENDDA'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 9.

<FS>-OUTPUTLEN = 10.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-H18.

<FS>-HOTSPOT = 'X'.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'AEDAT'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 10.

<FS>-OUTPUTLEN = 10.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-H15.

<FS>-HOTSPOT = 'X'.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'AENAM'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 11.

<FS>-OUTPUTLEN = 15.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-H19.

<FS>-HOTSPOT = 'X'.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'REASON'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-COL_POS = 12.

<FS>-OUTPUTLEN = 70.

<FS>-DDICTXT = 'L'.

<FS>-SELTEXT_L = TEXT-H21.

<FS>-HOTSPOT = 'X'.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'INFTY'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-TECH = GC_X.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'SUBTY'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-TECH = GC_X.

ENDIF.

READ TABLE XT_FCAT WITH KEY FIELDNAME = 'OBJPS'

ASSIGNING <FS>.

IF SY-SUBRC = 0.

<FS>-TECH = GC_X.

ENDIF.

ENDFORM. " FIELDCAT_BUILD_ALV