Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Credit Memo Details Report

Hi,

I am developing Credit Memo Details report, here user wants all the details of Credit Memo including Acct Docu Number based on Reference number.

The report is working fine if the Credit memo has account docu number, but now user wants this report to work if Cmemo does not have ACCtDocuNum also.

If ACCtDocuNum is not there, it has to display the remaining fields.

Can I use VBAK, VBAP and VBFA combination. Getting vbeln from VBAK based on s_XBLNR. Get item info from VBAP. Then get ACCTDOCUNUM from VBFA based on VBAK-VBELN and VBAP-POSNR.

Please help me if I am correct or should I use different table combination.

Thanks,

Neelu.

FORM get_data.

SELECT avbeln aposnr avgbel anetwr afkimg amatnr

bvkorg bvtweg bspart bkunag bxblnr bbstnk_vf

FROM vbrp AS a

INNER JOIN vbrk AS b

ON avbeln = bvbeln

INTO TABLE ivbrkp

WHERE b~xblnr IN s_xblnr

AND b~fkart = 'ZMKD'.

IF sy-subrc = 0.

SELECT kunnr matnr sprice eprice eohqty bstkd crmemo

FROM zppprice INTO TABLE izppprice

FOR ALL ENTRIES IN ivbrkp

WHERE kunnr = ivbrkp-kunag

AND matnr = ivbrkp-matnr

AND crmemo = ivbrkp-vgbel.

ENDIF.

ENDFORM. " get_data

&----


*& Form process_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM process_data.

DATA: lv_name1 LIKE kna1-name1,

lv_auart LIKE vbak-auart,

lv_augru LIKE vbak-augru,

lv_werks LIKE vbap-werks,

lv_fkdat LIKE vbkd-fkdat,

lv_knumv LIKE vbak-knumv,

lv_kbetr LIKE konv-kbetr.

LOOP AT ivbrkp.

g_bqty = ivbrkp-fkimg.

MOVE ivbrkp-vbeln TO iout-vbeln.

MOVE ivbrkp-posnr TO iout-posnr.

MOVE ivbrkp-vgbel TO iout-vgbel.

MOVE ivbrkp-netwr TO iout-netwr.

MOVE g_bqty TO iout-g_bqty.

MOVE ivbrkp-vkorg TO iout-vkorg.

MOVE ivbrkp-vtweg TO iout-vtweg.

MOVE ivbrkp-spart TO iout-spart.

MOVE ivbrkp-kunag TO iout-kunnr.

MOVE ivbrkp-matnr TO iout-matnr.

MOVE ivbrkp-xblnr TO iout-xblnr.

MOVE ivbrkp-bstnk_vf TO iout-bstnk_vf.

READ TABLE izppprice WITH KEY kunnr = ivbrkp-kunag

matnr = ivbrkp-matnr

crmemo = ivbrkp-vgbel.

g_qdiff = izppprice-eohqty - g_bqty.

IF sy-subrc = 0.

MOVE izppprice-sprice TO iout-sprice.

MOVE izppprice-eprice TO iout-eprice.

MOVE izppprice-eohqty TO iout-eohqty.

MOVE g_qdiff TO iout-g_qdiff.

ENDIF.

SELECT SINGLE name1

FROM kna1 INTO lv_name1 WHERE kunnr = ivbrkp-kunag.

IF sy-subrc = 0.

MOVE lv_name1 TO iout-name1.

ENDIF.

SELECT SINGLE auart augru FROM vbak INTO (lv_auart, lv_augru)

WHERE vbeln = ivbrkp-vgbel.

IF sy-subrc = 0.

MOVE lv_auart TO iout-auart.

MOVE lv_augru TO iout-augru.

ENDIF.

SELECT SINGLE werks FROM vbap INTO lv_werks

WHERE vbeln = ivbrkp-vgbel

AND posnr = ivbrkp-posnr.

IF sy-subrc = 0.

MOVE lv_werks TO iout-werks.

ENDIF.

SELECT SINGLE fkdat FROM vbkd INTO lv_fkdat

WHERE vbeln = ivbrkp-vgbel.

IF sy-subrc = 0.

MOVE lv_fkdat TO iout-fkdat.

ENDIF.

SELECT SINGLE knumv

FROM vbak INTO lv_knumv

WHERE vbeln = ivbrkp-vgbel.

SELECT SINGLE kbetr

FROM konv INTO lv_kbetr

WHERE knumv = lv_knumv

AND kschl = 'ZCPP'.

IF sy-subrc = 0.

MOVE lv_kbetr TO iout-g_pdiff.

ENDIF.

APPEND iout.

CLEAR iout.

CLEAR ivbrkp.

CLEAR lv_name1.

CLEAR lv_auart.

CLEAR lv_augru.

CLEAR lv_werks.

CLEAR lv_fkdat.

CLEAR lv_knumv.

CLEAR lv_kbetr.

ENDLOOP.

ENDFORM. " process_data

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question