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: 

ALV Grid

Former Member
0 Kudos

Is it possible to do this with ALV grid

have a line above the columns to show sub topic, something like:-

To Quay

From Quay

col1 | col2 | col3 | col4 |col5 | col6 | col7 |

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Ur requirement is not possible in ALV Grid but it is possible in ALV Hierachical report....

Here i am sending sample code for ur refference....please test it in ur system

&----


*& Report ZHER *

*& *

&----


*& *

*& *

&----


REPORT ZHER. "#EC NEEDED

*REPORT ZALV_HIERARCHIAL.

TYPE-POOLS:SLIS.

TABLES: EKKO,EKPO.

DATA : BEGIN OF IT_EKKO OCCURS 0,

EBELN LIKE EKKO-EBELN,

BUKRS LIKE EKKO-BUKRS,

LIFNR LIKE EKKO-LIFNR,

BEDAT LIKE EKKO-BEDAT,

END OF IT_EKKO.

DATA : BEGIN OF IT_EKPO OCCURS 0,

SNO LIKE EKPO-EBELN,

EBELP LIKE EKPO-EBELP,

MENGE LIKE EKPO-MENGE,

NETWR LIKE EKPO-NETWR,

END OF IT_EKPO.

DATA V_REPID LIKE SY-REPID.

DATA IT_FIELDCAT TYPE SLIS_FIELDCAT_ALV OCCURS 0 WITH HEADER LINE.

DATA X_KEYINFO TYPE SLIS_KEYINFO_ALV.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS:S_EBELN FOR EKKO-EBELN.

SELECTION-SCREEN END OF BLOCK B1.

sy-title = ''.

INITIALIZATION.

V_REPID = SY-REPID.

*S_EBELN-LOW = '4500000000'.

*S_EBELN-SIGN = 'I'.

*S_EBELN-OPTION = 'EQ'.

*S_EBELN-HIGH = '6000000270'.

*APPEND S_EBELN.

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM GET_FIELD.

PERFORM GET_KEY.

PERFORM KEY_MODIFY.

PERFORM DISPLAY.

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA.

SELECT EBELN BUKRS LIFNR BEDAT

FROM EKKO

INTO TABLE IT_EKKO UP TO 20 ROWS

WHERE EBELN IN S_EBELN.

SELECT EBELN EBELP MENGE NETWR

FROM EKPO

INTO TABLE IT_EKPO UP TO 20 ROWS

WHERE EBELN IN S_EBELN.

ENDFORM. " get_data

&----


*& Form get_field

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_FIELD.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'IT_EKKO'

I_INCLNAME = V_REPID

CHANGING

CT_FIELDCAT = IT_FIELDCAT[].

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'IT_EKPO'

I_INCLNAME = V_REPID

CHANGING

CT_FIELDCAT = IT_FIELDCAT[]

*=

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

WRITE : 'NOT SUCCESS'.

ENDIF.

ENDFORM. " get_field

&----


*& Form get_key

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_KEY.

X_KEYINFO-HEADER01 = 'EBELN'.

X_KEYINFO-ITEM01 = 'SNO'.

ENDFORM. " get_key

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID

IT_FIELDCAT = IT_FIELDCAT[]

I_TABNAME_HEADER = 'IT_EKKO'

I_TABNAME_ITEM = 'IT_EKPO'

IS_KEYINFO = X_KEYINFO

TABLES

T_OUTTAB_HEADER = IT_EKKO

T_OUTTAB_ITEM = IT_EKPO

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

WRITE : 'NOT SUCCESS'.

ENDIF.

ENDFORM. " DISPLAY

&----


*& Form key_modify

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM KEY_MODIFY.

LOOP AT IT_FIELDCAT. "Avoid Repitiotion of data.

CASE IT_FIELDCAT-FIELDNAME.

WHEN 'SNO'.

IF IT_FIELDCAT-TABNAME = 'IT_EKPO'.

IT_FIELDCAT-NO_OUT = 'X'.

IT_FIELDCAT-KEY = SPACE.

ENDIF.

ENDCASE.

MODIFY IT_FIELDCAT INDEX SY-TABIX.

ENDLOOP.

ENDFORM. " key_modif

reward me if it is use full answer.

praveen

5 REPLIES 5

Former Member
0 Kudos

no it's not possible.

regards

Sameer

Former Member
0 Kudos

hi,

I think this is possible through Hierarchical ALV

Former Member
0 Kudos

With ALV grid , you can not do this.

But with ALV list - <b>YES.</b>

You can refer to transaction ME28 ( Purcahse Order Release). The output will be like that only.

Hope it helps.

Former Member
0 Kudos

Hi,

Ur requirement is not possible in ALV Grid but it is possible in ALV Hierachical report....

Here i am sending sample code for ur refference....please test it in ur system

&----


*& Report ZHER *

*& *

&----


*& *

*& *

&----


REPORT ZHER. "#EC NEEDED

*REPORT ZALV_HIERARCHIAL.

TYPE-POOLS:SLIS.

TABLES: EKKO,EKPO.

DATA : BEGIN OF IT_EKKO OCCURS 0,

EBELN LIKE EKKO-EBELN,

BUKRS LIKE EKKO-BUKRS,

LIFNR LIKE EKKO-LIFNR,

BEDAT LIKE EKKO-BEDAT,

END OF IT_EKKO.

DATA : BEGIN OF IT_EKPO OCCURS 0,

SNO LIKE EKPO-EBELN,

EBELP LIKE EKPO-EBELP,

MENGE LIKE EKPO-MENGE,

NETWR LIKE EKPO-NETWR,

END OF IT_EKPO.

DATA V_REPID LIKE SY-REPID.

DATA IT_FIELDCAT TYPE SLIS_FIELDCAT_ALV OCCURS 0 WITH HEADER LINE.

DATA X_KEYINFO TYPE SLIS_KEYINFO_ALV.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS:S_EBELN FOR EKKO-EBELN.

SELECTION-SCREEN END OF BLOCK B1.

sy-title = ''.

INITIALIZATION.

V_REPID = SY-REPID.

*S_EBELN-LOW = '4500000000'.

*S_EBELN-SIGN = 'I'.

*S_EBELN-OPTION = 'EQ'.

*S_EBELN-HIGH = '6000000270'.

*APPEND S_EBELN.

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM GET_FIELD.

PERFORM GET_KEY.

PERFORM KEY_MODIFY.

PERFORM DISPLAY.

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA.

SELECT EBELN BUKRS LIFNR BEDAT

FROM EKKO

INTO TABLE IT_EKKO UP TO 20 ROWS

WHERE EBELN IN S_EBELN.

SELECT EBELN EBELP MENGE NETWR

FROM EKPO

INTO TABLE IT_EKPO UP TO 20 ROWS

WHERE EBELN IN S_EBELN.

ENDFORM. " get_data

&----


*& Form get_field

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_FIELD.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'IT_EKKO'

I_INCLNAME = V_REPID

CHANGING

CT_FIELDCAT = IT_FIELDCAT[].

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'IT_EKPO'

I_INCLNAME = V_REPID

CHANGING

CT_FIELDCAT = IT_FIELDCAT[]

*=

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

WRITE : 'NOT SUCCESS'.

ENDIF.

ENDFORM. " get_field

&----


*& Form get_key

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_KEY.

X_KEYINFO-HEADER01 = 'EBELN'.

X_KEYINFO-ITEM01 = 'SNO'.

ENDFORM. " get_key

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID

IT_FIELDCAT = IT_FIELDCAT[]

I_TABNAME_HEADER = 'IT_EKKO'

I_TABNAME_ITEM = 'IT_EKPO'

IS_KEYINFO = X_KEYINFO

TABLES

T_OUTTAB_HEADER = IT_EKKO

T_OUTTAB_ITEM = IT_EKPO

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

WRITE : 'NOT SUCCESS'.

ENDIF.

ENDFORM. " DISPLAY

&----


*& Form key_modify

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM KEY_MODIFY.

LOOP AT IT_FIELDCAT. "Avoid Repitiotion of data.

CASE IT_FIELDCAT-FIELDNAME.

WHEN 'SNO'.

IF IT_FIELDCAT-TABNAME = 'IT_EKPO'.

IT_FIELDCAT-NO_OUT = 'X'.

IT_FIELDCAT-KEY = SPACE.

ENDIF.

ENDCASE.

MODIFY IT_FIELDCAT INDEX SY-TABIX.

ENDLOOP.

ENDFORM. " key_modif

reward me if it is use full answer.

praveen

Former Member
0 Kudos

it cant be done the way i would have hoped - thanks for the replies