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: 

How 2 get Column name & Sub column name in ALV ?

Former Member
0 Kudos
204

Dear ALV gurus

How 2 get Column name & Sub column name in ALV ?

E.G

a => column name

b c d => sub column name

Credit Note => column name

-


MaterialCost|Overriding Charges |Total|=>sub col name

Thanx

Moni

Message was edited by: md monirujjaman

Message was edited by: md monirujjaman

1 ACCEPTED SOLUTION

Former Member
0 Kudos
43

Hi,

I guess u r talking about hierarchial ALV?

Sample code

*&----


*

*& Form list_data

*&----


*

  • Display data in an hierahical list

*&----


*

Form list_data.

Data: lt_fieldcat Type Table Of slis_fieldcat_alv,

ls_keyinfo Type slis_keyinfo_alv,

ls_variant Like disvariant,

ls_layout Type slis_layout_alv.

Data:

ls_pos Like Line Of gt_pos.

Clear gs_data.

Loop At gt_data Into gs_data.

Loop At gs_data-stpo Into ls_pos.

Append ls_pos To gt_pos.

EndLoop.

EndLoop.

Perform fill_catalog

Tables lt_fieldcat.

ls_keyinfo-header01 = 'MATNR'.

ls_keyinfo-item01 = 'MATNR'.

ls_keyinfo-header02 = 'STLNR'.

ls_keyinfo-item02 = 'STLNR'.

Clear ls_variant.

ls_variant-report = sy-repid.

Clear ls_layout.

Call Function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = ls_variant-report

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

IS_LAYOUT = ls_layout

IT_FIELDCAT = lt_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 = 'GT_DATA'

I_TABNAME_ITEM = 'GT_POS'

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

IS_KEYINFO = ls_keyinfo

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB_HEADER = gt_data

T_OUTTAB_ITEM = gt_pos

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

*&----


*

*& Form FILL_CATALOG

*&----


*

  • fill field catalog for alv with values

*----


*

Form fill_catalog

Tables

t_fieldcat.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_DATA' 'MATNR' '' '1' 'Material'(h01) '' '20'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_DATA' 'WERKS' '' '2' 'Werk'(h02) '' '4'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_DATA' 'DISPO' '' '3' 'Disponent'(h03) '' ''."'3'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_DATA' 'STLNR' '' '4' 'Stückliste'(h04) '' ''."'8'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_POS' 'POSNR' '' '1' 'Position'(h05) '5' ''."'4'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_POS' 'IDNRK' '' '2' 'Komponente'(h06) '' '20'.

  • Perform add_field_to_catalog

  • Tables

  • t_fieldcat

  • Using

  • 'GT_POS' 'DISMM' '' '3' 'Dispomerkm'(h07) '' ''."'2'.

  • Perform add_field_to_catalog

  • Tables

  • t_fieldcat

  • Using

  • 'GT_POS' 'DISPO' '' '4' 'Disponent_komp'(h08) '' ''."'3'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_POS' 'DSPST' '' '5' 'Auflösung' '' ''."'2'.

EndForm. "fill_catalog

*&----


*

*& Form ADD_FIELD_TO_CATALOG

*&----


*

  • Add a line to field catalog

  • Tables

  • t_fieldcat

  • Using

  • value(p_tabname)

  • value(p_fieldname)

  • value(p_tech)

  • value(p_col_pos)

  • value(p_seltext_l)

  • value(p_outputlen).

*----


*

Form add_field_to_catalog

Tables

t_fieldcat

Using

value(p_tabname)

value(p_fieldname)

value(p_tech)

value(p_col_pos)

value(p_seltext_l)

value(p_offset)

value(p_outputlen).

Data ls_fcat Type slis_fieldcat_alv.

ls_fcat-tabname = p_tabname.

ls_fcat-fieldname = p_fieldname.

ls_fcat-tech = p_tech.

ls_fcat-col_pos = p_col_pos.

ls_fcat-seltext_l = p_seltext_l.

ls_fcat-outputlen = p_outputlen.

ls_fcat-offset = p_offset.

Append ls_fcat To t_fieldcat.

EndForm. "add_field_to_catalog

Try this out.

Thanks & Regards,

Judith.

2 REPLIES 2

athavanraja
Active Contributor
0 Kudos
43

Can we have little more explanation on your question.

Regards

Raja

Former Member
0 Kudos
44

Hi,

I guess u r talking about hierarchial ALV?

Sample code

*&----


*

*& Form list_data

*&----


*

  • Display data in an hierahical list

*&----


*

Form list_data.

Data: lt_fieldcat Type Table Of slis_fieldcat_alv,

ls_keyinfo Type slis_keyinfo_alv,

ls_variant Like disvariant,

ls_layout Type slis_layout_alv.

Data:

ls_pos Like Line Of gt_pos.

Clear gs_data.

Loop At gt_data Into gs_data.

Loop At gs_data-stpo Into ls_pos.

Append ls_pos To gt_pos.

EndLoop.

EndLoop.

Perform fill_catalog

Tables lt_fieldcat.

ls_keyinfo-header01 = 'MATNR'.

ls_keyinfo-item01 = 'MATNR'.

ls_keyinfo-header02 = 'STLNR'.

ls_keyinfo-item02 = 'STLNR'.

Clear ls_variant.

ls_variant-report = sy-repid.

Clear ls_layout.

Call Function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = ls_variant-report

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

IS_LAYOUT = ls_layout

IT_FIELDCAT = lt_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 = 'GT_DATA'

I_TABNAME_ITEM = 'GT_POS'

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

IS_KEYINFO = ls_keyinfo

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB_HEADER = gt_data

T_OUTTAB_ITEM = gt_pos

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

*&----


*

*& Form FILL_CATALOG

*&----


*

  • fill field catalog for alv with values

*----


*

Form fill_catalog

Tables

t_fieldcat.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_DATA' 'MATNR' '' '1' 'Material'(h01) '' '20'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_DATA' 'WERKS' '' '2' 'Werk'(h02) '' '4'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_DATA' 'DISPO' '' '3' 'Disponent'(h03) '' ''."'3'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_DATA' 'STLNR' '' '4' 'Stückliste'(h04) '' ''."'8'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_POS' 'POSNR' '' '1' 'Position'(h05) '5' ''."'4'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_POS' 'IDNRK' '' '2' 'Komponente'(h06) '' '20'.

  • Perform add_field_to_catalog

  • Tables

  • t_fieldcat

  • Using

  • 'GT_POS' 'DISMM' '' '3' 'Dispomerkm'(h07) '' ''."'2'.

  • Perform add_field_to_catalog

  • Tables

  • t_fieldcat

  • Using

  • 'GT_POS' 'DISPO' '' '4' 'Disponent_komp'(h08) '' ''."'3'.

Perform add_field_to_catalog

Tables

t_fieldcat

Using

'GT_POS' 'DSPST' '' '5' 'Auflösung' '' ''."'2'.

EndForm. "fill_catalog

*&----


*

*& Form ADD_FIELD_TO_CATALOG

*&----


*

  • Add a line to field catalog

  • Tables

  • t_fieldcat

  • Using

  • value(p_tabname)

  • value(p_fieldname)

  • value(p_tech)

  • value(p_col_pos)

  • value(p_seltext_l)

  • value(p_outputlen).

*----


*

Form add_field_to_catalog

Tables

t_fieldcat

Using

value(p_tabname)

value(p_fieldname)

value(p_tech)

value(p_col_pos)

value(p_seltext_l)

value(p_offset)

value(p_outputlen).

Data ls_fcat Type slis_fieldcat_alv.

ls_fcat-tabname = p_tabname.

ls_fcat-fieldname = p_fieldname.

ls_fcat-tech = p_tech.

ls_fcat-col_pos = p_col_pos.

ls_fcat-seltext_l = p_seltext_l.

ls_fcat-outputlen = p_outputlen.

ls_fcat-offset = p_offset.

Append ls_fcat To t_fieldcat.

EndForm. "add_field_to_catalog

Try this out.

Thanks & Regards,

Judith.