05-28-2012 1:13 PM
Hi All,
I have made one ALV report. In my ALV report I have made 3 customized columns Billing,Receipt and Outstanding.
Now I have to calculate Outstanding Amount Using Billing and Receipt.Like
Row1 Row 2 Row3
Billing + Receipt = Outstanding1 ,then
Outstanding1 + Billing + Receipt = Outstanding
This is the way I have to show Outstanding on a zigzag method,
Moderator message - priority modified.
Thanks in Advance
Sankil
Message was edited by: Rob Burbank
05-29-2012 6:37 AM
Hellio Mr Desai,
I am here sending my Code just check me know where I am doing wrong.
*&---------------------------------------------------------------------*
*& Report ZCUST_DET *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZCUST_DET.
Tables:BSID,KNA1.
Type-pools: slis.
TYPES: Begin of w_BSID,
budat type BSID-budat,
belnr type BSID-belnr,
augbl type BSID-augbl,
zuonr type BSID-zuonr,
* wt_qbshh type with_item-wt_qbshh,
wrbtr type BSID-wrbtr,
qsskz type BSID-qsskz,
sgtxt type BSID-sgtxt,
gjahr type BSID-gjahr,
kunnr type BSID-kunnr,
bukrs type BSID-bukrs,
shkzg type BSID-shkzg,
billing type wrbtr,
receipt type wrbtr,
outstanding_1 type wrbtr,
outstanding type wrbtr,
end of w_BSID.
DATA: fields type slis_fieldcat_alv,
it_fieldcat type slis_t_fieldcat_alv,
layout type slis_layout_alv.
DATA: t_BSID type standard table of w_BSID with header line.
DATA wa_bsid type w_BSID. "Added By Swap
SELECTION-SCREEN: Begin of Block B1 with frame title Text-A01.
SELECT-OPTIONS: s_kunnr for BSID-kunnr,
s_bukrs for BSID-bukrs,
s_gjahr for BSID-gjahr,
s_budat for BSID-budat.
SELECTION-SCREEN: End of Block B1.
START-OF-SELECTION.
select budat bukrs gjahr belnr augbl zuonr wrbtr sgtxt shkzg qsskz kunnr from BSID into corresponding fields of table t_BSID
where
KUNNR IN s_KUNNR.
******
LOOP at t_BSID into wa_BSID.
if wa_BSID-shkzg = 'H'.
wa_BSID-billing = -1 * wa_BSID-wrbtr.
else.
wa_BSID-receipt = 1 * wa_BSID-wrbtr.
endif.
wa_BSID-Outstanding_1 = wa_BSID-billing + wa_BSID-receipt.
wa_BSID-Outstanding = wa_BSID-Outstanding_1 + wa_BSID-billing + wa_BSID-receipt.
MODIFY t_BSID FROM wa_BSID.
clear : wa_BSID.
ENDLOOP.
*****
*LOOP at t_BSID into wa_BSID.
*wa_BSID-outstanding = wa_BSID-billing + wa_BSID-receipt.
*endloop.
* move t_BSID-wrbtr to t_BSID-billing.
*select kunnr from kna1 into corresponding fields of t_BSID
*where
*kunnr IN s_kunnr.
*endselect.
*
*select wt_qbshh from with_item into corresponding fields of t_BSID
*where
*bukrs IN s_bukrs.
*endselect.
DATA: FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR FIELDCAT.
fields-col_pos = 1.
fields-fieldname = 'KUNNR' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Customer Number'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 2.
fields-fieldname = 'BUDAT' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Posting Date'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 3.
fields-fieldname = 'BELNR' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Document No'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 4.
fields-fieldname = 'AUGBL' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Clear doc'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 5.
fields-fieldname = 'ZUONR' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Assignment'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 6.
fields-fieldname = 'WT_QBSHH' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'WIthholding tax'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 7.
fields-fieldname = 'WRBTR' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Amount'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 8.
fields-fieldname = 'SGTXT' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Text'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 9.
fields-fieldname = 'SHKZG' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Debit/Credit Indicator'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 10.
fields-fieldname = 'BILLING' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Billing'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 11.
fields-fieldname = 'RECEIPT' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Receipt'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 12.
fields-fieldname = 'OUTSTANDING' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Outstanding'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
*if t_BSID-shkzg = 'H'.
*t_BSID-Billing = -1 * t_BSID-wrbtr.
*modify t_BSID.
*endif.
*
*if t_BSID-shkzg = 'S'.
*t_BSID-Receipt = 1 * t_BSID-wrbtr.
*endif.
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 = 'C_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 = layout
IT_FIELDCAT = it_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
* 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 = t_BSID
* 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.
Here I want Outstanding = Billing + Receipt and again in this Outstanding has to add next billing and receipt amount.in loop.
Thanks and Regards
Sankil Pandya
05-28-2012 1:22 PM
Hi,
Not getting your requirment ,,,,,may be this is your requirment,,,
loop at itab(say final internal table ) into wa."only reciepient ,billing data available
wa_outstandin = lv_outstand + wa_reciepient + wa_billing. "
lv_outstand = wa_outstandin.
modify itab from wa.
endloop.
call grid display
thanks and regards
05-28-2012 1:31 PM
Thanks for Response Mr Desai,
Calculation Like this
Billing + Receipt = Outstanding Then This Outstanding again add to Billing and receipt Amount so will get another Outstanding amount like this in loop.
05-28-2012 1:49 PM
Hi,
What i mentined above is exactly same wat you describing now,,,
consider same(refer above prev post) ,
Considered lit is final internal table contains 3 fields ,billing,rec,outst right?
within loop first run lv_oustandi is intial hence first one is sum of billin ,rec and storing to var lv_oustandin k.
in second loop this will (lv_oustanding) add to new billin,rece and store in outsing of same wa.
check the logic again ,,,,,
revert back if this is not clear'
Thanks and regards
05-28-2012 1:33 PM
Hi,
please see the below link
http://help.sap.com/erp2005_ehp_04/helpdata/en/fc/eb32e2358411d1829f0000e829fbfe/content.htm
you can also use add until using sequence
05-28-2012 1:45 PM
Hello,
Try :
Billing + Receipt = Outstanding
Outstanding = Outstanding + Billing + Receipt.
Regards.
05-29-2012 6:37 AM
Hellio Mr Desai,
I am here sending my Code just check me know where I am doing wrong.
*&---------------------------------------------------------------------*
*& Report ZCUST_DET *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZCUST_DET.
Tables:BSID,KNA1.
Type-pools: slis.
TYPES: Begin of w_BSID,
budat type BSID-budat,
belnr type BSID-belnr,
augbl type BSID-augbl,
zuonr type BSID-zuonr,
* wt_qbshh type with_item-wt_qbshh,
wrbtr type BSID-wrbtr,
qsskz type BSID-qsskz,
sgtxt type BSID-sgtxt,
gjahr type BSID-gjahr,
kunnr type BSID-kunnr,
bukrs type BSID-bukrs,
shkzg type BSID-shkzg,
billing type wrbtr,
receipt type wrbtr,
outstanding_1 type wrbtr,
outstanding type wrbtr,
end of w_BSID.
DATA: fields type slis_fieldcat_alv,
it_fieldcat type slis_t_fieldcat_alv,
layout type slis_layout_alv.
DATA: t_BSID type standard table of w_BSID with header line.
DATA wa_bsid type w_BSID. "Added By Swap
SELECTION-SCREEN: Begin of Block B1 with frame title Text-A01.
SELECT-OPTIONS: s_kunnr for BSID-kunnr,
s_bukrs for BSID-bukrs,
s_gjahr for BSID-gjahr,
s_budat for BSID-budat.
SELECTION-SCREEN: End of Block B1.
START-OF-SELECTION.
select budat bukrs gjahr belnr augbl zuonr wrbtr sgtxt shkzg qsskz kunnr from BSID into corresponding fields of table t_BSID
where
KUNNR IN s_KUNNR.
******
LOOP at t_BSID into wa_BSID.
if wa_BSID-shkzg = 'H'.
wa_BSID-billing = -1 * wa_BSID-wrbtr.
else.
wa_BSID-receipt = 1 * wa_BSID-wrbtr.
endif.
wa_BSID-Outstanding_1 = wa_BSID-billing + wa_BSID-receipt.
wa_BSID-Outstanding = wa_BSID-Outstanding_1 + wa_BSID-billing + wa_BSID-receipt.
MODIFY t_BSID FROM wa_BSID.
clear : wa_BSID.
ENDLOOP.
*****
*LOOP at t_BSID into wa_BSID.
*wa_BSID-outstanding = wa_BSID-billing + wa_BSID-receipt.
*endloop.
* move t_BSID-wrbtr to t_BSID-billing.
*select kunnr from kna1 into corresponding fields of t_BSID
*where
*kunnr IN s_kunnr.
*endselect.
*
*select wt_qbshh from with_item into corresponding fields of t_BSID
*where
*bukrs IN s_bukrs.
*endselect.
DATA: FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR FIELDCAT.
fields-col_pos = 1.
fields-fieldname = 'KUNNR' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Customer Number'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 2.
fields-fieldname = 'BUDAT' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Posting Date'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 3.
fields-fieldname = 'BELNR' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Document No'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 4.
fields-fieldname = 'AUGBL' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Clear doc'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 5.
fields-fieldname = 'ZUONR' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Assignment'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 6.
fields-fieldname = 'WT_QBSHH' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'WIthholding tax'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 7.
fields-fieldname = 'WRBTR' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Amount'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 8.
fields-fieldname = 'SGTXT' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Text'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 9.
fields-fieldname = 'SHKZG' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Debit/Credit Indicator'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 10.
fields-fieldname = 'BILLING' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Billing'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 11.
fields-fieldname = 'RECEIPT' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Receipt'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
fields-col_pos = 12.
fields-fieldname = 'OUTSTANDING' .
fields-tabname = 't_BSID'.
fields-seltext_l = 'Outstanding'.
fields-outputlen = 10 .
fieldcat-hotspot = 'X'.
APPEND fields TO it_fieldcat.
CLEAR fields.
*if t_BSID-shkzg = 'H'.
*t_BSID-Billing = -1 * t_BSID-wrbtr.
*modify t_BSID.
*endif.
*
*if t_BSID-shkzg = 'S'.
*t_BSID-Receipt = 1 * t_BSID-wrbtr.
*endif.
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 = 'C_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 = layout
IT_FIELDCAT = it_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
* 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 = t_BSID
* 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.
Here I want Outstanding = Billing + Receipt and again in this Outstanding has to add next billing and receipt amount.in loop.
Thanks and Regards
Sankil Pandya
05-29-2012 7:11 AM
Hi,
Output as per your current logic.
SR. NO | BILLING | RECEIPT | OUTSTANDING |
1 | 100 | 200 | 600 |
2 | 200 | 200 | 800 |
3 | 300 | 300 | 1200 |
I am assuming that you are trying to achieve the below output.
SR. NO | BILLING | RECEIPT | OUTSTANDING |
1 | 100 | 200 | 300 |
2 | 200 | 200 | 700 |
3 | 300 | 300 | 1300 |
Follow the below approch to achieve this.
DATA: W_OUTSTANDIG_PRE TYPE WRBTR.
******
LOOP at t_BSID into wa_BSID.
if wa_BSID-shkzg = 'H'.
wa_BSID-billing = -1 * wa_BSID-wrbtr.
else.
wa_BSID-receipt = 1 * wa_BSID-wrbtr.
endif.
wa_bsid-outstanding1 = wa_BSID-billing + wa_BSID-receipt.
ADD wa_bsid-outstanding1 TO w_outstanding_pre.
wa_BSID-Outstanding = w_outstanding_pre.
MODIFY t_BSID FROM wa_BSID.
clear : wa_BSID.
ENDLOOP.
*****
05-29-2012 7:34 AM
Thank You very Much Mr VIjayMathur.
Problem has resolved
Once Again Thank you very Much
also Thanks to Mr Desai.