Application Development and Automation 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: 
Read only

Doubt in ALV

Former Member
0 Likes
1,258

Hi,

I have a doubt in ALV.

I need to display both item level details and header details in my ALV.

After i display line items i should display another row which has header details and display sum of some coloumns in the item details. Like if i order 3 items.

order num Posnr Qty

5678 1item- 10

2 20

3 30

then

header row has

order no. qty

5678 60

How do wee do that?

pls help.

Thanks,

Das

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,229

hI,

Go through this porgram. This program might be solve ur problem.

REPORT ALV_HIRARCHECIAL_REPORT.

TABLES : VBAK.

TYPE-POOLS SLIS.

SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN.

DATA : IT_VBAK LIKE VBAK OCCURS 0 WITH HEADER LINE,

IT_VBAP LIKE VBAP OCCURS 0 WITH HEADER LINE,

IT_KEYINFO TYPE SLIS_KEYINFO_ALV,

IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA : R_NAME LIKE SY-REPID.

INITIALIZATION.

R_NAME = SY-REPID.

START-OF-SELECTION.

SELECT * FROM VBAK INTO TABLE IT_VBAK

WHERE VBELN IN S_VBELN.

SELECT * FROM VBAP INTO TABLE IT_VBAP

WHERE VBELN IN S_VBELN.

*PERFORM FIELDCAT.

IT_KEYINFO-HEADER01 = 'VBELN'.

IT_KEYINFO-ITEM01 = 'VBELN'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = R_NAME

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

  • IT_FIELDCAT = IT_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 = ' '

  • IS_VARIANT = ' '

  • IT_EVENTS =

  • IT_EVENT_EXIT =

I_TABNAME_HEADER = 'IT_VBAK'

I_TABNAME_ITEM = 'IT_VBAP'

I_STRUCTURE_NAME_HEADER = 'VBAK'

I_STRUCTURE_NAME_ITEM = 'VBAP'

IS_KEYINFO = IT_KEYINFO

  • IS_PRINT =

  • IS_REPREP_ID =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB_HEADER = IT_VBAK

T_OUTTAB_ITEM = IT_VBAP

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

&----


*& Form FIELDCAT

&----


  • text

----


FORM FIELDCAT.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = R_NAME

  • I_INTERNAL_TABNAME =

I_STRUCTURE_NAME = 'IT_VBAK'

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = R_NAME

I_BYPASSING_BUFFER = 'X'

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = IT_FIELDCAT

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

ENDFORM. " FIELDCAT

Regards,

Rajneesh Gupta

Hi,

I have a doubt in ALV.

I need to display both item level details and header details in my ALV.

After i display line items i should display another row which has header details and display sum of some coloumns in the item details. Like if i order 3 items.

order num Posnr Qty

5678 1item- 10

2 20

3 30

then

header row has

order no. qty

5678 60

How do wee do that?

pls help.

Thanks,

Das

9 REPLIES 9
Read only

Former Member
0 Likes
1,229

for sum there is a property in fieldcatalog DO_SUM set this to 'X'.

for doing sum of columns.

Vivek

Read only

Former Member
0 Likes
1,229

Use function module REUSE_ALV_HIERSEQ_LIST_DISPLAY

Read only

Former Member
0 Likes
1,229

Hi,

Before calling ALV function module,

Loop at the internal table.

at end of document number.

Calculate the sum of required fileds.

insert into internal table which you are passing to ALV function modules.

endat.

endloop.

Sort internal table by document number and posnr.

Read only

0 Likes
1,229

Check out transaction LIBS.

There are many examples on how to do to build a list with multiple headers!

You can check program ERGP2350 to see how build a multiple header list.

Hope this helps,

R.

Read only

0 Likes
1,229

Thank you for all replies.

Read only

Former Member
0 Likes
1,229

Hi,

1) Create a sort internal table with the order number field

2) have the DO_SUM = 'X' for the quantity field in the field catalog internal table..

Thanks,

Naren

Read only

0 Likes
1,229

Hi,

But i have a coloumn which shows %. i can't add them using subtotals. What i have done is i collected my data in two internal tables.

One has Sales header details in it.The other has sales item details. Now i want to print as...header level followed by item level for each document number.

How to do that?

Thanks,

Das

Read only

Former Member
0 Likes
1,230

hI,

Go through this porgram. This program might be solve ur problem.

REPORT ALV_HIRARCHECIAL_REPORT.

TABLES : VBAK.

TYPE-POOLS SLIS.

SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN.

DATA : IT_VBAK LIKE VBAK OCCURS 0 WITH HEADER LINE,

IT_VBAP LIKE VBAP OCCURS 0 WITH HEADER LINE,

IT_KEYINFO TYPE SLIS_KEYINFO_ALV,

IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA : R_NAME LIKE SY-REPID.

INITIALIZATION.

R_NAME = SY-REPID.

START-OF-SELECTION.

SELECT * FROM VBAK INTO TABLE IT_VBAK

WHERE VBELN IN S_VBELN.

SELECT * FROM VBAP INTO TABLE IT_VBAP

WHERE VBELN IN S_VBELN.

*PERFORM FIELDCAT.

IT_KEYINFO-HEADER01 = 'VBELN'.

IT_KEYINFO-ITEM01 = 'VBELN'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = R_NAME

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

  • IT_FIELDCAT = IT_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 = ' '

  • IS_VARIANT = ' '

  • IT_EVENTS =

  • IT_EVENT_EXIT =

I_TABNAME_HEADER = 'IT_VBAK'

I_TABNAME_ITEM = 'IT_VBAP'

I_STRUCTURE_NAME_HEADER = 'VBAK'

I_STRUCTURE_NAME_ITEM = 'VBAP'

IS_KEYINFO = IT_KEYINFO

  • IS_PRINT =

  • IS_REPREP_ID =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB_HEADER = IT_VBAK

T_OUTTAB_ITEM = IT_VBAP

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

&----


*& Form FIELDCAT

&----


  • text

----


FORM FIELDCAT.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = R_NAME

  • I_INTERNAL_TABNAME =

I_STRUCTURE_NAME = 'IT_VBAK'

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = R_NAME

I_BYPASSING_BUFFER = 'X'

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = IT_FIELDCAT

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

ENDFORM. " FIELDCAT

Regards,

Rajneesh Gupta

Read only

0 Likes
1,229

Thank you all. Rajneesh your code was helpful.

By the way i wanted to ask if we cannot do this using grid display.

Thanks,

Das