04-23-2015 5:07 AM
Hi My dear ,
SAP Abap consultants,
please help me in resolving this issue.
There is a standard transaction called FB03.
Where we need to provide document number ,company code , fiscal year these three parameters should be passed as a parameters and we need to genreate an alv from BKPF (header Data) & BSEG( line item)
in bseg there is a field called WRBTR ( Called Amount field )
let me quote the example
-12
+12
-12
+12
now my requirement is we have to add three columns in total two are amount fields in which what ever the amount which are negative should be displayed in first column positive in second column and over all sum in third column
-12 0 -12
0 +12 0
-12 0 -12
0 +12 0
in third column sum of first row should need to carry forward to next row. this is the one which i recieved as some variant
there shold be change in the row counts finally the total sum value should be the addition and difference of all fields
Please help me in designining Alv in this format.
appreciate your help
04-23-2015 5:36 AM
Hi Prasanna Kumar,
To achecive this in ALV first u need to perform the logic in report as below
1) first design ur internal table as per the output you need like (12 0 -12) .
2) Loop the beseg table and check the amount field WRBTR < 0 if so then set this to the negative field else to the positive value and use collect statement so that u will get the third column sum values.
Hope this will work.
Regards,
Vinodkumar.
04-23-2015 5:36 AM
Hi Prasanna Kumar,
To achecive this in ALV first u need to perform the logic in report as below
1) first design ur internal table as per the output you need like (12 0 -12) .
2) Loop the beseg table and check the amount field WRBTR < 0 if so then set this to the negative field else to the positive value and use collect statement so that u will get the third column sum values.
Hope this will work.
Regards,
Vinodkumar.
04-23-2015 5:42 AM
Hi Vinod,
Thanks for your reply..
actually there is only one field with amount in which we need to add one more colmn with the same data types and negative values in one column and positive values in another column which should be split from first column wherever split we need to keep the rest wiyth 0 and sum should carry to the next row as well.
hope u have provided some logic.
04-23-2015 5:49 AM
Hi Prasanna,
To achieve u can try based on credit/debit Indicator(+/-) in table BSEG and field name SHKZG. Based on the indicator you can calculate and display.
Regards,
Basavaraj
04-23-2015 5:53 AM
Thanks Basavraj will try and let you know .
thanks for your update.
04-23-2015 6:02 AM
Also you can try using the FM " CLOI_PUT_SIGN_IN_FRONT" to display the negative sign in front of the value in the report.
04-23-2015 9:05 AM
Hi Hyma ,
thanks for your reply but I need to seperate Negative values in to one column and positive in to some another column
need the final caluculation of both columns at end of all final rows
04-29-2015 1:25 PM
*&---------------------------------------------------------------------*
*& Report Z_FI_ALV
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_fi_alv.
TABLES:bseg.
TYPES:BEGIN OF it_bseg,
bukrs TYPE bseg-bukrs,
buzei TYPE bseg-buzei,
koart TYPE bseg-koart,
hkont TYPE bseg-hkont,
prctr TYPE bseg-prctr,
shkzg TYPE bseg-shkzg,
wrbtr TYPE bseg-wrbtr,
END OF it_bseg.
TYPES:BEGIN OF it_bseg1,
bukrs TYPE bseg-bukrs,
buzei TYPE bseg-buzei,
koart TYPE bseg-koart,
hkont TYPE bseg-hkont,
prctr TYPE bseg-prctr,
wrbtr_s TYPE bseg-wrbtr,
wrbtr_h TYPE bseg-wrbtr,
total TYPE bseg-wrbtr,
END OF it_bseg1.
DATA:it_bseg_alv TYPE TABLE OF it_bseg,
wa_bseg_alv TYPE it_bseg.
DATA:it_bseg1_alv TYPE TABLE OF it_bseg1,
wa_bseg1_alv TYPE it_bseg1.
TYPE-POOLS:slis.
DATA:it_fcat TYPE slis_t_fieldcat_alv,
wa_fcat TYPE slis_fieldcat_alv.
SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:bukrs FOR bseg-bukrs,
belnr FOR bseg-belnr,
gjahr FOR bseg-gjahr.
SELECTION-SCREEN END OF BLOCK b1.
SELECT bukrs buzei koart hkont prctr shkzg wrbtr FROM bseg INTO TABLE it_bseg_alv
WHERE bukrs IN bukrs AND belnr IN belnr AND gjahr IN gjahr.
IF sy-subrc EQ 0.
REFRESH it_bseg1_alv.
LOOP AT it_bseg_alv INTO wa_bseg_alv.
wa_bseg1_alv-bukrs = wa_bseg_alv-bukrs.
wa_bseg1_alv-buzei = wa_bseg_alv-buzei.
wa_bseg1_alv-koart = wa_bseg_alv-koart.
wa_bseg1_alv-hkont = wa_bseg_alv-hkont.
wa_bseg1_alv-prctr = wa_bseg_alv-prctr.
IF wa_bseg_alv-shkzg EQ 'S'.
wa_bseg1_alv-wrbtr_s = wa_bseg_alv-wrbtr.
wa_bseg1_alv-wrbtr_h = 0.
wa_bseg1_alv-total = wa_bseg1_alv-wrbtr_s + wa_bseg1_alv-wrbtr_h + wa_bseg1_alv-total.
ELSE.
wa_bseg1_alv-wrbtr_h = 0 - wa_bseg_alv-wrbtr.
wa_bseg1_alv-wrbtr_s = 0.
wa_bseg1_alv-total = wa_bseg1_alv-wrbtr_h + wa_bseg1_alv-wrbtr_s + wa_bseg1_alv-total.
ENDIF.
APPEND wa_bseg1_alv TO it_bseg1_alv.
ENDLOOP.
ENDIF.
REFRESH it_fcat.
wa_fcat-col_pos = '1'.
wa_fcat-fieldname = 'BUKRS'.
wa_fcat-tabname = 'IT_BSEG1_ALV'.
wa_fcat-seltext_l = 'COMPANY CODE'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = '2'.
wa_fcat-fieldname = 'BUZEI'.
wa_fcat-tabname = 'IT_BSEG1_ALV'.
wa_fcat-seltext_l = 'ITEM NAME'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = '3'.
wa_fcat-fieldname = 'KOART'.
wa_fcat-tabname = 'IT_BSEG1_ALV'.
wa_fcat-seltext_l = 'Account Type'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = '4'.
wa_fcat-fieldname = 'HKONT'.
wa_fcat-tabname = 'IT_BSEG1_ALV'.
wa_fcat-seltext_l = 'General Ledger Account'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = '5'.
wa_fcat-fieldname = 'PRCTR'.
wa_fcat-tabname = 'IT_BSEG1_ALV'.
wa_fcat-seltext_l = 'Profit Center'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = '6'.
wa_fcat-fieldname = 'WRBTR_S'.
wa_fcat-tabname = 'IT_BSEG1_ALV'.
wa_fcat-seltext_l = 'credited amount.'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = '7'.
wa_fcat-fieldname = 'WRBTR_H'.
wa_fcat-tabname = 'IT_BSEG1_ALV'.
wa_fcat-seltext_l = 'debited amount.'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = '8'.
wa_fcat-fieldname = 'TOTAL'.
wa_fcat-tabname = 'IT_BSEG1_ALV'.
wa_fcat-seltext_l = 'total amount'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-cprog
* 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 = it_bseg1_alv
* I_BACKGROUND_ID = ' '
i_grid_title = 'ALV Report for CREDIT & DEBIT '
* I_GRID_SETTINGS = I_GRID_SETTINGS
* IS_LAYOUT = IS_LAYOUT
it_fieldcat = it_fcat
* IT_EXCLUDING = IT_EXCLUDING
* IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
* IT_SORT = IT_SORT
* IT_FILTER = IT_FILTER
* IS_SEL_HIDE = IS_SEL_HIDE
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT = IS_VARIANT
* IT_EVENTS = IT_EVENTS
* IT_EVENT_EXIT = IT_EVENT_EXIT
* IS_PRINT = IS_PRINT
* IS_REPREP_ID = IS_REPREP_ID
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS = IT_ALV_GRAPHICS
* IT_HYPERLINK = IT_HYPERLINK
* IT_ADD_FIELDCAT = IT_ADD_FIELDCAT
* IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
* IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
* ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
TABLES
t_outtab = it_bseg1_alv
* EXCEPTIONS
* PROGRAM_ERROR = 1
.
04-29-2015 1:39 PM
here i am facing an eroor that i will be able to caluculate sum if the docmnet number gets cahnged previous total is being carried to the next one as well can any one please confirm this
04-30-2015 2:33 AM
Hi prasanna,
Based on which conditions amount field to summed i.e for doc numbers or gl account ?.
eg: considering doc no as assumption.
keep doc no as first field, sort the internal table by doc no.
LOOP AT it_bseg_alv INTO wa_bseg_alv.
AT END OF BELNR.
APPEND wa_bseg1_alv TO it_bseg1_alv.
CLEAR wa_bseg1.
ENDAT.
ENDLOOP.
OR you can use collect statement.
Hope it helpful,
Regards,
Venkat.V
04-30-2015 9:25 PM
Hi venkat,
i tried using that but i am not getting the correct format for single document number i am getting the output but in select options if we provide two options the first document total is being populated to next document number total.
please check it once
05-01-2015 2:18 AM
Hi prasanna,
Delcare belnr(Doc no) as first field in internal table.
before loop sort by belnr.
loop at itab.
at new belnr.
clear wa.
end at.
at end of belnr.
append wa to itab1.
endat.
endloop.
Hope it helpful,
Regards,
Venkat