Skip to Content
0
Former Member
May 08, 2010 at 04:31 AM

Profit center wise credit/debit calculation

59 Views

Hi, SAP guru's

My vendor have required profit center wise cedit/debit calculation. I did this coading but in gt_list it append one blank line.due to this when i want to calculate the final debit credit it wont give proper value.please help me...

SELECT prctr dmbtr shkzg

FROM bsik

INTO TABLE gt_bsik

WHERE lifnr = s_lifnr AND bukrs = s_bukrs AND prctr <> ' '.

SORT gt_bsik BY prctr.

LOOP AT gt_bsik INTO gs_bsik WHERE shkzg = 'H'.

lv_prctr = gs_bsik-prctr.

AT NEW prctr.

lv_prctr = gs_bsik-prctr.

APPEND gs_list TO gt_list.

CLEAR lv_pr_dmbtr1.

ENDAT.

IF sy-subrc = 0.

lv_pr_dmbtr1 = lv_pr_dmbtr1 + gs_bsik-dmbtr.

ENDIF.

gs_list-prctr = lv_prctr.

gs_list-dmbtr = lv_pr_dmbtr1.

gs_list-shkzg = 'H'.

ENDLOOP.

APPEND gs_list TO gt_list.

CLEAR lv_prctr.

CLEAR gs_list.

LOOP AT gt_bsik INTO gs_bsik WHERE shkzg = 'S'.

AT NEW prctr.

lv_prctr = gs_bsik-prctr.

APPEND gs_list TO gt_list.

CLEAR lv_pr_dmbtr2.

ENDAT.

IF sy-subrc = 0.

lv_pr_dmbtr2 = lv_pr_dmbtr2 + gs_bsik-dmbtr.

ENDIF.

gs_list-prctr = lv_prctr.

gs_list-dmbtr = lv_pr_dmbtr2.

gs_list-shkzg = 'S'.

ENDLOOP.