Copy Controls in SAP SD

Copy Control User Exits

Tweet

Related Trainings

SAP Training

SAP SD Training

SAP Access

Copy control functionlaity controls what data is copied from the source document to the subsequent document. Copy control functionlaity is used in the following scenarios.

  • Delivery creation from Sales order.
  • Billing document creation from Delivery document.
  • Billing document creation from the sales order.
  • Sales document creation with reference to a sales order or billing document or a quote.

Copy control has two levels of control, one is at the header and another is at the item level. Header data is specified based on the source document type and destination document type. A data copy routine presents at the header level. When business requires to send a new field from the source document to destination document, the fields should be added in this routine. SAP provides standard routines for copying standard fields. If a custom field needs to be copied , then copy the standard routine and create a custom program and edit it. This should be done in VOFM transaction. A requirement routine field also present at the header level. This routine controls weather a subsequent document is allowed or not. Copy controls will be covered in full as part of SAP SD Training.

Ex : A billing document should be created with reference to order, only when the sales order is delivered.

Similar to the header, item level also have copy routine and requirement routine. These routines can be modified in VOFM routine.

The following is the sample code to stop the creation of the billing document creation with reference to anorder, when there is no delivery document associated with the sales order.

FORM BEDINGUNG_PRUEFEN_990.
SY-SUBRC = 0.
CHECK : ANALYZE_MODE IS INITIAL.
* No check for offsetting down payment entries
CHECK FPLT-FAREG NA CON_FAREG_ANZAHLUNGEN.
* Billing block
IF VBAP-FAKSP NE SPACE.
SELECT SINGLE * FROM TVFSP WHERE FAKSP = VBAP-FAKSP
AND FKART = TVFK-FKART.
IF SY-SUBRC = 0.
PERFORM VBFS_HINZUFUEGEN USING VBAP-POSNR ‘015’ SPACE
SPACE SPACE.
SY-SUBRC = 4.
EXIT.
ENDIF.
SY-SUBRC = 0.
ENDIF.
* Billing block on billing plan
IF NOT VBRP-FPLNR IS INITIAL.
IF FPLT-FAKSP NE SPACE.
SELECT SINGLE * FROM TVFSP WHERE FAKSP = FPLT-FAKSP
AND FKART = TVFK-FKART.
IF SY-SUBRC = 0.
PERFORM VBFS_HINZUFUEGEN USING VBAP-POSNR ‘136’ FPLT-AFDAT
SPACE SPACE.
SY-SUBRC = 4.
EXIT.
ENDIF.
SY-SUBRC = 0.
ENDIF.
* Billing status in billing plan
IF FPLT-FKSAF EQ SPACE.
PERFORM VBFS_HINZUFUEGEN USING VBAP-POSNR ‘143’ FPLT-AFDAT
SPACE SPACE.
SY-SUBRC = 4.
EXIT.
ENDIF.
IF FPLT-FKSAF EQ ‘C’.
PERFORM VBFS_HINZUFUEGEN USING VBAP-POSNR ‘142’ FPLT-AFDAT
SPACE SPACE.
SY-SUBRC = 4.
EXIT.
ENDIF.
ENDIF.
* Billing status
IF VBUP-FKSAA = ‘ ‘.
PERFORM VBFS_HINZUFUEGEN_ALLG
USING VBAP-VBELN VBAP-POSNR ‘VF’ ‘I’ ‘044’
SPACE SPACE SPACE SPACE.
SY-SUBRC = 4.
EXIT.
ENDIF.
* Billing status
IF VBUP-FKSAA = ‘C’.
PERFORM VBFS_HINZUFUEGEN USING VBAP-POSNR ‘045’ SPACE SPACE SPACE.
SY-SUBRC = 4.
EXIT.
ENDIF.
* Delivery Status
data : temp_vbeln like vbap-vbeln.
data : temp_vbeln_rev like vbap-vbeln.
clear temp_vbeln.
select max( vbeln ) into temp_vbeln from vbfa
where vbelv = vbap-vbeln
and posnv = vbap-posnr
and vbtyp_n = ‘R’.
if temp_vbeln ”.
select max( vbeln ) into temp_vbeln_rev from vbfa
where vbelv = vbap-vbeln
and posnv = vbap-posnr
and vbtyp_n = ‘h’.
if temp_vbeln_rev ”.
if temp_vbeln < temp_vbeln_rev.
PERFORM VBFS_HINZUFUEGEN USING VBAP-POSNR ‘066’ SPACE SPACE SPACE.
SY-SUBRC = 4.
EXIT.
endif.
endif.
else.
PERFORM VBFS_HINZUFUEGEN USING VBAP-POSNR ‘066’ SPACE SPACE SPACE.
SY-SUBRC = 4.
EXIT.
endif.
* Billing block in the customer master
IF KURGV-FAKSD NE SPACE.
SELECT SINGLE * FROM TVFSP WHERE FAKSP = KURGV-FAKSD
AND FKART = TVFK-FKART.
IF SY-SUBRC = 0.
PERFORM VBFS_HINZUFUEGEN USING ‘000000’ ‘068’ KURGV-KUNNR
SPACE SPACE.
SY-SUBRC = 4.
EXIT.
ENDIF.
SY-SUBRC = 0.
ENDIF.
ENDFORM. “BEDINGUNG_PRUEFEN_990

Click here for SAP Training.

0 thoughts on “Copy Controls in SAP SD

  1. Mickey says:

    When I initially commented I clicked the “Notify me when new comments are added” checkbox and
    now each time a comment is added I get several emails with the same comment.

    Is there any way you can remove me from that service?
    Cheers!

    Like

  2. Loretta says:

    I was wondering if you ever considered changing the page layout of
    your website? Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people
    could connect with it better. Youve got an awful lot of
    text for only having 1 or two pictures. Maybe you could space it out better?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s