Skip to Content

Adding default line items on VA01/VA21 based on Incoterms

Hi Experts,

Is there a way to add a default line items (material list) on the Quotation/Sales Order creation based on the Incoterms, I was able to do that but I have to hardcode some data since I don't know where to get it. Here are my code:

check vbkd-inco1 is not initial.

select

makt~matnr

makt~maktx

zmilssd01~etenr

into corresponding fields of table it_mara

from zmilssd01

inner join makt on maktmatnr eq zmilssd01matnr

where spart eq vbak-spart

and inco1 eq vbkd-inco1.

if zzinco1 ne vbkd-inco1.

refresh: xvbap, ivbap, xvbep, ivbep.

clear: xvbap, ivbap, xvbep, ivbep.

endif.

clear p_ctr.

sort it_mara by etenr.

if it_mara[] is not initial and xvbap[] is initial..

loop at it_mara.

clear vbap.

add 1 to p_ctr.

vbap-mandt = vbak-mandt.

vbap-vbeln = vbak-vbeln.

  • HARD-CODED PART *************************************

vbap-matkl = 'FFS'.

vbap-pstyv = 'AGX'.

vbap-zieme = 'AU'.

vbap-umziz = 1.

vbap-umzin = 1.

vbap-meins = 'AU'.

vbap-spart = 'SE'.

vbap-gsber = 'C9S3'.

vbap-netwr = 0.

vbap-waerk = 'MYR'.

vbap-antlf = 9.

vbap-vrkme = 'AU'.

vbap-gewei = 'KG'.

vbap-erlre = 'B'.

vbap-werks = 'C902'.

vbap-vstel = 'FFS1'.

vbap-erdat = sy-datum.

vbap-ernam = sy-uname.

vbap-erzet = sy-uzeit.

vbap-umvkz = 1.

vbap-umvkn = 1.

  • HARD-CODED PART *************************************

p_posnr = p_ctr * 10.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = p_posnr

importing

output = vbap-posnr.

vbap-matnr = it_mara-matnr.

vbap-matwa = it_mara-matnr.

vbap-arktx = it_mara-maktx.

move vbap to xvbap.

xvbap-updkz = 'I'.

append xvbap.

ivbap-posnr = vbap-posnr.

ivbap-tabix = p_ctr.

append ivbap.

endloop.

zzinco1 = vbkd-inco1.

endif.

I just want to know where to get the data of the hardcoded part given only the material number (just like on the VA21/VA01 item screen where you only need to input material number and the XVAP/IVBAP table was auto populated.)

By the way, I used exit of MV45AFZZ form userexit_move_field_to_vbak to input my code.

Thanks,

Eric

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Oct 18, 2011 at 02:14 AM

    Hi Roderick

    I just want to know where to get the data of the hardcoded part given only the material number (just like on the VA21/VA01 item screen where you only need to input material number and the XVAP/IVBAP table was auto populated

    I did not get this. It looks like you are getting materials from custom table depending on incoterms. Here do you want to add line items in va01?. If that is a requirement you have to use standard includes in your custom report.

    Regards,

    Madhu.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Madhu,

      My problem is after my code in the user exit (please see below) was executed the table VBKD is refresh (or set to default):

      if sy-tcode eq 'VA21'.

      check vbkd-inco1 is not initial.

      select * from zmilssd01 into table it_mara

      where spart eq vbak-spart

      and inco1 eq vbkd-inco1.

      if zzinco1 ne vbkd-inco1.

      refresh: xvbap, ivbap, xvbep, ivbep, ivbep1.

      clear: xvbap, ivbap, xvbep, ivbep, ivbep1.

      endif.

      clear lv_tabix.

      sort it_mara by etenr.

      if it_mara[] is not initial.

      check xvbap[] is initial.

      loop at it_mara into wa_mara.

      add 1 to lv_tabix.

      clear: vbap.

      perform vbap_unterlegen(sapfv45p).

      perform vbep_unterlegen(sapfv45e).

      vbap-matnr = wa_mara-matnr.

      lv_posnr = lv_tabix * 10.

      call function 'CONVERSION_EXIT_ALPHA_INPUT'

      exporting

      input = lv_posnr

      importing

      output = vbap-posnr.

      perform vbap-matnr_pruefen(sapfv45p) using charx sy-subrc.

      perform vbap-pstyv_pruefen(sapfv45p).

      perform vbap_fuellen(sapfv45p).

      perform vbap-matnr_null_pruefen(sapfv45p).

      perform vbep-wmeng_setzen(sapfv45e).

      perform vbap-vrkme_pruefen(sapfv45p) using charx

      changing sy-subrc sy-msgid sy-msgty sy-msgno

      sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      perform vbap_bearbeiten(sapfv45p).

      perform vbep_fuellen(sapfv45e).

      perform vbep-wmeng_pruefen(sapfv45e) using charx

      changing sy-subrc sy-msgid sy-msgty sy-msgno

      sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      perform vbep_bearbeiten(sapfv45e).

      endloop.

      perform vbap_bearbeiten_ende(sapfv45p).

      endif.

      zzinco1 = vbkd-inco1.

      endif.

      This is I think because of the routine that being called after the user exit:

      perform userexit_move_field_to_vbak(sapmv45a).

      perform vbkd_fuellen.

      The routine perform vbkd_fuellen reset the VBKD.

      Is there another way or code that you can provide to get the same result?

      Many thanks,

      Eric