Skip to Content
0
Former Member
Nov 21, 2006 at 11:36 AM

Passing Credit Control Area during Create Sales Order using CreateFromDat1?

210 Views

I am currently in the development of Web Ordering project interface with SAP SD R/3 470, IS Oil&Gas.

How can I Passing Credit Control Area during Create Sales Order using JCO calling SalesOrder CreateFromDat1 (BAPI_SALESORDER_CREATEFROMDAT1)? I have tried to find http://ifr.sap.com - SAP LO - 470 > Sales and Distribution > Sales > SalesOrder > CreateFromDat1 / CreateFromDat2 / CreateFromData but there are no such parameter related to Credit Control Area.

From my customer user exit, I need to check if the payment term is 'OCBD' then set credit control area to 2000 instead of 1000 (Default) if not the error shows as follows. There is a user exit handle this in SAP UI but my situation is creating from Java Web Application/JCO.

2006-11-20 13:27:04,248 [QuartzScheduler_Worker-7] ERROR com.mfatix.bcpwo.job.SalesOrderCreationJob - 
java.lang.Exception: Critical credit data changed
	at com.mfatix.bcpwo.service.sap.SalesOrderService.createSalesOrderFromPurchaseOrder(SalesOrderService.java:173)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)

And the user exit as follows.

Program MV45AFZZ User exit USEREXIT_SAVE_DOCUMENT_PREPARE

If payment term (VBKD-ZTERM) = “OCBD” then credit control area of the document (VBAK-KKBER) = 2000

Add source code in the Program ZXVVAU03.

Exit function EXIT_SAPFV45K_001.

Component FV45K001.

IF IVBAK-vbtyp = 'C' or
     IVBAK-vbtyp = 'H' or
     IVBAK-vbtyp = 'K' or
     IVBAK-vbtyp = 'L'.
    IF sy-tcode = 'VA01' OR                               
       sy-tcode = 'VA02'.                                 
      IMPORT zterm FROM MEMORY ID 'ZTERM'.
      MOVE zterm TO ivbkd-zterm.
    ENDIF.                                                

      IF IVBKD-ZTERM = 'OCBD'.
        DA_KKBER  = '2000'.
      ELSE.
        DA_KKBER  = '1000'.
      ENDIF.
    ENDIF.


Include program ZISD_SD28_READ_FIELD_ZTERM
*Read payment term from screen
DATA: BEGIN OF l_dynpfield_tab OCCURS 2.
          INCLUDE STRUCTURE dynpread.
  DATA: END OF l_dynpfield_tab.

  DATA: l_prog LIKE d020s-prog,
        l_dnum LIKE d020s-dnum,
        zterm  LIKE vbkd-zterm.

  DATA: lc_zterm LIKE dynpread-fieldname VALUE 'VBKD-ZTERM'.

  IF sy-tcode = 'VA01' OR sy-tcode = 'VA02'
  or sy-tcode = 'VA21' OR sy-tcode = 'VA22'.
    MOVE: sy-dynnr TO l_dnum,
          sy-repid TO l_prog.

    REFRESH l_dynpfield_tab.
    MOVE lc_zterm TO l_dynpfield_tab-fieldname.
    APPEND l_dynpfield_tab.

    CALL FUNCTION 'DYNP_VALUES_READ'
         EXPORTING
              dyname               = l_prog
              dynumb               = l_dnum
              translate_to_upper   = 'X'
         TABLES
              dynpfields           = l_dynpfield_tab
         EXCEPTIONS
              invalid_abapworkarea = 01
              invalid_dynprofield  = 02
              invalid_dynproname   = 03
              invalid_dynpronummer = 04
              invalid_request      = 05
              no_fielddescription  = 06
              undefind_error       = 07.

    CHECK sy-subrc IS INITIAL.
    READ TABLE l_dynpfield_tab WITH KEY fieldname = lc_zterm.
    MOVE l_dynpfield_tab-fieldvalue TO zterm.
    EXPORT zterm TO MEMORY ID 'ZTERM'.
  ENDIF.

Thank you in advance,

Surapong

surapong@mfatix.com

Mfatix Co., Ltd.

http://www.mfatix.com