cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP code error.

Former Member
0 Kudos

Dear Experts,

In the below abap code i am facing the problem of goods returns and other issues.

becoz of that my code add the qty & value of that invoices.

please give me suggestion.

Please go through the bold area.

SELECT-OPTIONS : s_spart FOR vbrk-spart,

s_kunag FOR vbrk-kunag,

s_fkdat FOR vbrk-fkdat OBLIGATORY.

*--


end of selection--


SELECT vbrk~spart

vbrk~vbeln

vbrk~kunag

vbrk~kurrf

vbrk~netwr

vbrk~fkdat

vbrp~mwsbp

vbrp~fkimg

vbak~auart

INTO CORRESPONDING FIELDS OF TABLE i_vbrk

FROM vbrk

INNER JOIN vbrp

ON vbrpvbeln = vbrkvbeln

INNER JOIN vbak

on vbakvbeln = vbrpaubel

WHERE vbrk~spart IN s_spart

AND vbrk~kunag IN s_kunag

AND vbrk~fkdat IN s_fkdat

AND VBRK~VBTYP IN ('M','O','P')

AND vbrk~vkorg = 'JS01'

AND vbrk~fksto NE 'X'

AND vbrk~rfbsk = 'C'.

SELECT knkk~kunnr

knkk~klimk

kna1~name1

INTO CORRESPONDING FIELDS OF TABLE i_knkk

FROM knkk

INNER JOIN kna1

ON knkkkunnr = kna1kunnr

WHERE kna1~kunnr IN s_kunag.

LOOP AT i_vbrk.

IF i_vbrk-auart = 'ZJCR' OR i_vbrk-auart = 'ZJDR' OR i_vbrk-auart = 'ZJC1'.

CLEAR i_vbrk-fkimg.

clear i_vbrk-vlinr.

ENDIF.

IF i_vbrk-mwsbp <> 0.

i_vbrk-netwr = i_vbrk-netwr + i_vbrk-mwsbp.

ENDIF.

IF i_vbrk-kurrf <> 1.

*i_vbrk-vlinr = i_vbrk-netwr * i_vbrk-kurrf.*

ELSE.

i_vbrk-vlinr = i_vbrk-netwr.

ENDIF.

IF i_vbrk-auart = 'ZJRE'

OR i_vbrk-auart = 'ZJCR'

OR i_vbrk-auart = 'ZJC1'

OR i_vbrk-auart = 'ADTC'

OR i_vbrk-auart = 'ZJR1'

OR i_vbrk-auart = 'ZJKR'

OR i_vbrk-auart = 'ZJBR'.

    • it_main-netwr = it_main-netwr * -1.*

*i_vbrk-vlinr = i_vbrk-vlinr * -1.*

*i_vbrk-fkimg = i_vbrk-fkimg * -1.*

ENDIF.

CLEAR :i_vbrk-mwsbp, i_vbrk-netwr, i_vbrk-kurrf." i_vbrk-fkimg.

MODIFY i_vbrk. "INDEX V_INDEX.

ENDLOOP.

LOOP AT i_vbrk.

  • MOVE I_VBRK-KUNAG TO I_FINAL-KUNNR.

  • MOVE I_VBRK-FKDAT TO I_FINAL-FKDAT.

  • MOVE I_VBRK-FKIMG TO I_FINAL-FKIMG.

clear i_vbrk-auart.

IF i_vbrk-fkdat+4(02) = '01'.

  • i_KNKK-month = 'JAN'.

i_vbrk-janq = i_vbrk-fkimg.

i_vbrk-jana = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '02'.

  • i_KNKK-month = 'FEB'.

i_vbrk-febq = i_vbrk-fkimg.

i_vbrk-feba = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '03'.

  • i_KNKK-month = 'MAR'.

i_vbrk-marq = i_vbrk-fkimg.

i_vbrk-mara = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '04'.

  • i_KNKK-month = 'APR'.

i_vbrk-aprq = i_vbrk-fkimg.

i_vbrk-apra = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '05'.

  • i_KNKK-month = 'MAY'.

i_vbrk-mayq = i_vbrk-fkimg.

i_vbrk-maya = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '06'.

  • i_KNKK-month = 'JUN'.

i_vbrk-junq = i_vbrk-fkimg.

i_vbrk-juna = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '07'.

  • i_KNKK-month = 'JUL'.

i_vbrk-julq = i_vbrk-fkimg.

i_vbrk-jula = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '08'.

  • i_KNKK-month = 'AUG'.

i_vbrk-augq = i_vbrk-fkimg.

i_vbrk-auga = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '09'.

  • i_KNKK-month = 'SEP'.

i_vbrk-sepq = i_vbrk-fkimg.

i_vbrk-sepa = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '10'.

  • i_KNKK-month = 'OCT'.

i_vbrk-octq = i_vbrk-fkimg.

i_vbrk-octa = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '11'.

  • i_KNKK-month = 'NOV'.

i_vbrk-novq = i_vbrk-fkimg.

i_vbrk-nova = i_vbrk-vlinr / 100000.

ENDIF.

IF i_vbrk-fkdat+4(02) = '12'.

  • i_KNKK-month = 'DEC'.

i_vbrk-decq = i_vbrk-fkimg.

i_vbrk-deca = i_vbrk-vlinr / 100000.

ENDIF.

  • MODIFY i_KNKK.

MODIFY i_vbrk. "INDEX V_INDEX.

ENDLOOP.

CLEAR : i_VBRK-FKDAT, i_vbrk-vbeln.

DATA : ii_vbrk LIKE i_vbrk OCCURS 0 WITH HEADER LINE.

LOOP AT i_VBRK.

CLEAR : i_VBRK-FKDAT, i_vbrk-vbeln,i_vbrk-auart.

COLLECT i_vbrk INTO ii_vbrk.

  • MODIFY i_VBRK.

ENDLOOP.

*LOOP AT i_knkk.

  • IF i_final-kunag = knkk-kunnr.

  • APPEND i_final.

  • ENDIF.

*ENDLOOP.

DATA : V(3) TYPE C.

CLEAR v_index.

LOOP AT ii_vbrk.

v_index = sy-TABIX.

READ TABLE i_knkk WITH KEY kunnr = ii_vbrk-kunag.

IF SY-SUBRC = 0.

MOVE i_knkk-klimk TO ii_vbrk-klimk.

MOVE i_knkk-name1 TO ii_vbrk-name1.

  • MOVE I_KNKK-MONTH TO II_VBRK-MONTH.

MODIFY ii_vbrk INDEX v_index.

ENDIF.

ENDLOOP.

LOOP AT ii_vbrk.

ii_vbrk-klimk = ii_vbrk-klimk / 100000.

II_VBRK-VLINR = II_VBRK-jana + II_VBRK-feba + II_VBRK-mara + II_VBRK-apra + II_VBRK-maya + II_VBRK-juna + II_VBRK-jula + II_VBRK-auga + II_VBRK-sepa + II_VBRK-octa + II_VBRK-nova + II_VBRK-deca.

PEAK_QTY = II_VBRK-JANQ.

PEAK_AMT = II_VBRK-JANA.

PEAK_MONTH = 'JAN'.

IF PEAK_AMT LT II_VBRK-FEBA.

PEAK_QTY = II_VBRK-FEBQ.

PEAK_AMT = II_VBRK-FEBA.

PEAK_MONTH = 'FEB'.

ENDIF.

IF PEAK_AMT LT II_VBRK-MARA.

PEAK_QTY = II_VBRK-MARQ.

PEAK_AMT = II_VBRK-MARA.

PEAK_MONTH = 'MAR'.

ENDIF.

IF PEAK_AMT LT II_VBRK-APRA.

PEAK_QTY = II_VBRK-APRQ.

PEAK_AMT = II_VBRK-APRA.

PEAK_MONTH = 'APR'.

ENDIF.

IF PEAK_AMT LT II_VBRK-MAYA.

PEAK_QTY = II_VBRK-MAYQ.

PEAK_AMT = II_VBRK-MAYA.

PEAK_MONTH = 'MAY'.

ENDIF.

IF PEAK_AMT LT II_VBRK-JUNA.

PEAK_QTY = II_VBRK-JUNQ.

PEAK_AMT = II_VBRK-JUNA.

PEAK_MONTH = 'JUN'.

ENDIF.

IF PEAK_AMT LT II_VBRK-JULA.

PEAK_QTY = II_VBRK-JULQ.

PEAK_AMT = II_VBRK-JULA.

PEAK_MONTH = 'JUL'.

ENDIF.

IF PEAK_AMT LT II_VBRK-AUGA.

PEAK_QTY = II_VBRK-AUGQ.

PEAK_AMT = II_VBRK-AUGA.

PEAK_MONTH = 'AUG'.

ENDIF.

IF PEAK_AMT LT II_VBRK-SEPA.

PEAK_QTY = II_VBRK-SEPQ.

PEAK_AMT = II_VBRK-SEPA.

PEAK_MONTH = 'SEP'.

ENDIF.

IF PEAK_AMT LT II_VBRK-OCTA.

PEAK_QTY = II_VBRK-OCTQ.

PEAK_AMT = II_VBRK-OCTA.

PEAK_MONTH = 'OCT'.

ENDIF.

IF PEAK_AMT LT II_VBRK-NOVA.

PEAK_QTY = II_VBRK-NOVQ.

PEAK_AMT = II_VBRK-NOVA.

PEAK_MONTH = 'NOV'.

ENDIF.

IF PEAK_AMT LT II_VBRK-DECA.

PEAK_QTY = II_VBRK-DECQ.

PEAK_AMT = II_VBRK-DECA.

PEAK_MONTH = 'DEC'.

ENDIF.

  • II_VBRK-VLINR = II_VBRK-jana + II_VBRK-feba + II_VBRK-mara + II_VBRK-apra + II_VBRK-maya + II_VBRK-juna + II_VBRK-jula + II_VBRK-auga + II_VBRK-sepa + II_VBRK-octa + II_VBRK-nova + II_VBRK-deca.

II_VBRK-FKIMG = PEAK_QTY.

II_VBRK-peaka = PEAK_AMT.

II_VBRK-MONTH = PEAK_MONTH.

MODIFY II_VBRK.

ENDLOOP.

SORT ii_vbrk BY SPART.

Thanks

DSRAJPUT

Accepted Solutions (0)

Answers (1)

Answers (1)

tomislavkolonic
Employee
Employee
0 Kudos

Hi,

could you please try to format your coding nicely (see Markup Possibilities). There is also a possibility to attach files.

BR,

Tomislav