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: 

Report !!!!

Former Member
0 Kudos

Hi gurus,

I have a problem !!!!

I am working on a report...where I need to get the document number from table BKPF and then I need to get the line item data from table BSEG such as gross amount and Net amount, then I need to sum up the gross amount and net amount of one header and need to display it. ...

My scenario is like this:

doc # item# Gross amount Net amount

123 1 12 10

123 2 12 9

123 3 13 11

124 1 15 13

So the output should be:

doc # Gross amount Net amount

123 37 30

124 15 13

so can yoy please tell me how can I take care of this....

Any help will really be appreciated !!!! actually I am trying to learn!!!

Thanks,

Rajeev !!!!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Rajeev,

Have you written some code.

If you are stuck up at some place then let us know so that we can help you.

Regards,

Atish

11 REPLIES 11

Former Member
0 Kudos

Hi Rajeev,

Have you written some code.

If you are stuck up at some place then let us know so that we can help you.

Regards,

Atish

0 Kudos

Atish so far I have not written much..can you please tell me the approcah for it....so that I can start with it !!! then If I get stuck I will definitely get back to you !!!

Thanks,

Rajeev

0 Kudos

Hi Rajeev,

Use AT END..just type this key word and do F1 help on it..

At the end of document number add it and u can store it in another internal table.

Try to search in SDN and u can find lot of answers to u r stuff..

and als a small suggestion try to follow the rules. Just giving a subject as a REPORT is not a good idea.

Hope you understand.

Thanks

Chaithanya K

0 Kudos

Hi Rajiv,

There will be just two simple SELECT queries on BKPF and BSEF table.

First select data from BKPF into internal table then SELECT from BSEG USING FOR ALL ENTRIES for the first internal table.

Just give some try by doing F1 on key-word SELECT.

Regards,

Atish

0 Kudos

Hi Atish,

I have started coding:

data: begin of it_bkpf occurs 0,

belnr like bkpf-belnr,

end of it_bkpf.

data: begin of it_bseg occurs 0,

belnr like bseg-belnr,

end of it_bseg.

select belnr into table it_bkpf

from bkpf

where blart eq 'SA'.

loop at it_bseg.

write: /1 it_bseg-belnr.

Now I need to select the document number from BSEG which are there in it_bkpf and put that one in the other internal table, So can you please tell me how can I get this.

Thanks,

Rajeev

0 Kudos

Hi Rajeev,

I guess following code wouuld help you.

1.select from the reuired tables.

2. sort on keys which in this case would be document nuber.

3.Loop at tab1.

Loop at tab2 where docnum = tab1-docnum.

do the calculation.

endloop.

Pass on the value n document number to tab3.

append and clear .

endloop.

Display the tab3

Do eward if found useful

Regards,

Rajashree

Former Member
0 Kudos

Hi Rajeev,

I will send a sample code 4 u. ok.i only thing u did is u have to change the table name and internal table fileds according to ur requirement.I dont have enough time to develop the code ok.refer the below that is helpful to u.

code:

&----


*& Report YSALESORDER_ALV_SUBTOTALS *

*& *

&----


*& DEVELOPER : KIRAN KUMAR.G *

*& PURPOSE : DISPLAYING SUBTOTALS FOR A PARTICULAR SALES DOC NO *

*& CREATION DT: 26/11/2007 *

*& REQUEST : ERPK900035 *

&----


REPORT ysalesorder_alv_subtotals.

----


  • Type Pools

----


TYPE-POOLS:slis.

----


  • Tables

----


TABLES: vbak, "Sales Document: Header Data

vbap. "Sales Document: Item Data

----


  • Global Structures

----


DATA:gt_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv,

gt_sortcat TYPE slis_t_sortinfo_alv,

wa_sortcat LIKE LINE OF gt_sortcat.

----


  • Internal Table

----


DATA: BEGIN OF gt_salesorder OCCURS 0,

vbeln LIKE vbak-vbeln, " Sales Document Number

posnr LIKE vbap-posnr, " Sales Doc Item

netwr LIKE vbap-netwr, " Net Value

END OF gt_salesorder.

----


  • SELECT OPTIONS

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. " Sales Document Number.

SELECTION-SCREEN END OF BLOCK b1.

----


  • Initialization

----


INITIALIZATION.

PERFORM initialization.

----


  • Start Of Selection

----


START-OF-SELECTION.

PERFORM field_catalog. "For Structure Creation

PERFORM fetch_data. "Get the Data From DB Table

PERFORM sorting USING gt_sortcat.

----


  • End Of Selection

----


END-OF-SELECTION.

PERFORM display_data.

&----


*& Form initialization

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM initialization .

s_vbeln-sign = 'I'.

s_vbeln-option = 'BT'.

s_vbeln-low = '4969'.

s_vbeln-high = '5000'.

APPEND s_vbeln.

ENDFORM. " initialization

&----


*& Form field_catalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM field_catalog .

REFRESH : gt_fieldcat.

CLEAR : wa_fieldcat.

wa_fieldcat-col_pos = '1'. "Column Position

wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table

wa_fieldcat-fieldname = 'VBELN'. "Field Name

wa_fieldcat-key = 'X'. "Blue Color

wa_fieldcat-seltext_m = 'Sales Doc No'. "Display Text In Screen

APPEND wa_fieldcat TO gt_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = '2'. "Column Position

wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table Name

wa_fieldcat-fieldname = 'POSNR'. "Field Name

wa_fieldcat-seltext_m = 'Sales Doc Item'."Display Text In Screen

APPEND wa_fieldcat TO gt_fieldcat.

CLEAR wa_fieldcat.

*SubTotal on the Field NETWR

wa_fieldcat-col_pos = '3'. "Column Position

wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table

wa_fieldcat-fieldname = 'NETWR'. "Field Name

wa_fieldcat-do_sum = 'X'. "Sum

wa_fieldcat-seltext_m = 'Net Value'. "Display Text In Screen

APPEND wa_fieldcat TO gt_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. " field_catalog

&----


*& Form sorting

&----


  • text

----


  • -->P_IT_SORTCAT text

----


FORM sorting USING p_it_sortcat TYPE slis_t_sortinfo_alv.

CLEAR wa_sortcat.

wa_sortcat-fieldname = 'VBELN'.

wa_sortcat-up ='X'.

wa_sortcat-subtot = 'X'.

APPEND wa_sortcat TO p_it_sortcat.

ENDFORM. " sorting

&----


*& Form display_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_data .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = sy-repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = gt_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = gt_sortcat

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = gt_salesorder

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

&----


*& Form fetch_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fetch_data .

REFRESH : gt_salesorder.

CLEAR : gt_salesorder.

SELECT a~vbeln

posnr

b~netwr

FROM vbak AS a

INNER JOIN vbap AS b ON avbeln = bvbeln

INTO TABLE gt_salesorder

WHERE a~vbeln IN s_vbeln.

ENDFORM. " fetch_data

Award points if helpful.

Kiran Kumar.G.A

Have a Nice Day..

Former Member
0 Kudos

hi rajeev,

i will give a simple example,

data : begin of it,

f1 value 'A',

f2 value 1, u can take any values and append them

f3 value 2,

end of it.

sort it by f1.

loop at it.

at new f1.

sum.

write:/ 'total',it-f1,it-f3.

endloop.

free it.

in ur problem give some if condition so that it checks with 123 and sums up the values...

pls reward points if helpful,

shylaja

0 Kudos

Hi guys,

I have tried and wrote the following code, can you please have a look at it and please let me know if I ned to make some changes.

&----


*& Report ZFI_PAYMENT *

*& *

&----


*& *

*& *

&----


REPORT ZFI_PAYMENT .

data : v_nebtr(15).

data: begin of it_bkpf occurs 0,

belnr like bkpf-belnr,

end of it_bkpf.

data: begin of it_bseg occurs 0,

belnr like bseg-belnr,

nebtr like bseg-nebtr,

end of it_bseg.

data : begin of it_fin occurs 0,

belnr like bseg-belnr,

nebtr like bseg-nebtr,

end of it_fin.

select belnr into table it_bkpf

from bkpf

where blart eq 'SA'.

select belnr into table it_bseg

from bseg

where belnr eq it_bkpf-belnr.

loop at it_bkpf.

read table it_bseg with key belnr = it_bkpf-belnr.

if sy-subrc eq 0.

ADD it_bseg-nebtr to v_nebtr.

else.

move it_bseg-nebtr to it_fin-nebtr.

move it_bseg-belnr to it_fin-belnr.

append it_fin.

clear it_fin.

endif.

it_bseg-nebtr = v_nebtr.

endloop.

Thanks,

Rajeev !!!

Former Member
0 Kudos

Hi,

Can you tell me on which BSEG field u r calculating gross amount?

Former Member
0 Kudos

Hi Rajeev,

Try this program !!!! Try to make it as per ur reqmnt

TYPES: BEGIN OF company,

name(20) TYPE c,

sales TYPE i,

END OF company.

DATA: comp TYPE STANDARD TABLE OF company,

comptab TYPE HASHED TABLE OF company

WITH UNIQUE KEY name,

wa_comptab TYPE company,

wa_comp TYPE company.

wa_comp-name = '123'.

wa_comp-sales = 10.

APPEND wa_comp TO comp.

CLEAR wa_comp.

wa_comp-name = '321'.

wa_comp-sales = 20.

APPEND wa_comp TO comp.

CLEAR wa_comp.

wa_comp-name = '621'.

wa_comp-sales = 20.

APPEND wa_comp TO comp.

CLEAR wa_comp.

wa_comp-name = '123'.

wa_comp-sales = 30.

APPEND wa_comp TO comp.

CLEAR wa_comp.

wa_comp-name = '621'.

wa_comp-sales = 1.

APPEND wa_comp TO comp.

CLEAR wa_comp.

LOOP AT comp INTO wa_comptab.

COLLECT wa_comptab INTO comptab.

ENDLOOP.

LOOP AT comptab INTO wa_comptab.

WRITE:/ wa_comptab-name , wa_comptab-sales.

CLEAR: wa_comptab.

ENDLOOP.

regards

Avi..........