cancel
Showing results for 
Search instead for 
Did you mean: 

Routine code examples

Former Member
0 Kudos

Hi,

Can any one give few examples of writing a routine VBRK/VBRP for a copy control.

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi

refer below link it may helps

<a href="http://sap.ittoolbox.com/groups/technical-functional/sap-log-sd/copy-control-billing-documents-807436">Copy Control</a>

former_member183879
Active Contributor
0 Kudos

This is a sample code for copy control routine.

----


  • FORM - Routine for data transfer when copying *

----


----


  • FORM DATEN_KOPIEREN_004 *

----


  • *

  • Item Partner from Billing *

  • *

  • In this routine, the item partners are copied. *

  • Partners will only be copied to the items if the sold-to *

  • party is identical. *

  • All partners are copied in this routine. *

  • Invalid partners are removed after this routine. *

  • Item partners that are identical with header partners are *

  • removed after this routine. *

  • Missing partners are filled in after this routine. *

  • *

  • The following work areas are available: *

  • *

  • Tables: *

  • XVBPA - Partner of the header of the order *

  • CVBPA - Partner of the header reference document *

  • Workaereas: *

  • VBAK - Header of the order *

  • CVBRK - Header of the reference document *

  • CVBRP - Item of the reference document *

  • *

----


FORM DATEN_KOPIEREN_004.

DATA: DA_TABIX LIKE SY-TABIX.

  • Copy only if the sold-to party is in the new order

XVBPA = SPACE.

XVBPA-PARVW = PARVW_AG.

READ TABLE XVBPA.

CHECK XVBPA-KUNNR CN '0 '.

  • Sold-to from the reference document

CVBPA = SPACE.

CVBPA-PARVW = PARVW_AG.

READ TABLE CVBPA.

  • Does the reference document have a partner or is it a sample document?

CHECK CVBPA-KUNNR CN '0 '.

  • Same Sold-to Party?

IF CVBPA-KUNNR = XVBPA-KUNNR.

  • Select the item

CVBPA-MANDT = CVBRP-MANDT.

CVBPA-VBELN = CVBRP-VBELN.

CVBPA-POSNR = CVBRP-VGPOS.

READ TABLE CVBPA WITH KEY CVBPA(19) BINARY SEARCH.

  • Copy the partner from the item

WHILE CVBPA-POSNR = CVBRP-VGPOS AND

SY-SUBRC = 0.

DA_TABIX = SY-TABIX + 1.

XVBPA = CVBPA.

XVBPA-POSNR = CVBRP-POSNR.

XVBPA-VBELN = VBAK-VBELN.

XVBPA-UPDKZ = UPDKZ_NEW.

APPEND XVBPA.

READ TABLE CVBPA INDEX DA_TABIX.

ENDWHILE.

ENDIF.

ENDFORM.

*eject

As already mentioned, you can go to tcode VOFM. In menu, copying reqmts, or data transfer and there you will get the list of routines. Select a routine and click teh Source text icon in the middle on your top left. This will display you the code.

Reward if this helps you

Former Member
0 Kudos

Hi, Thanks for the info.

I would like to know the code with proper syntax for copying the tax value from sales dcoument to billing doc in VBRP/VBRK data routine. i would like to make a small modification using the code to copy tax as 0 and not 1 in tax code.

Thanks

Former Member
0 Kudos

To view sample pricing routines go to transaction VOFM and click on Requirements / Pricing. You can view the code from here.