Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Line items to sales order on creation using User-Exit in VA01.

Former Member
0 Kudos

Hi All ,

I have a requirement where : in VA01 , i have to add new line items using USER EXIT or BADI.

The scenario is : we maintain Characteristics for Material. When we select a particular characteristics, Factor and length will be displayed in a Popup. we can specify the Factor and lenght.

Here , if i specify Factor as 10 and lenght as 1000. the Material has to be cut / split into 10 items of 1000 mts each. and the ITEMs table control should get 10 ITEMS .

How to add new items using User exit or Badi in VA01.

i have identified the user exit . What code should be used to add new line items.

Can we use BDC in a user exit ? is it possible?

kindly help me in solvng this.

Waiting for your replies.

Thanks in advance.

Suki.

7 REPLIES 7

Former Member
0 Kudos

Hi Suki

Did you find a solution to this? If anyone else has a solution to this requirement, please let me know.

Thanks

Graeme

vinod_vemuru2
Active Contributor
0 Kudos

Hi Suki,

We used BAPI to create the sales order as per our custom requirement inside the user exit MV45AFZZ and form

userexit_save_document_prepare. So instead of BDC u can use BAPI BAPI_SALESORDER_CREATEFROMDAT2. But make sure that this code will be executed only for ur requirements. U can code the logic as per the requirement and populate the BAPI item details table as per the Factor and length.

Hope this will help u.

Thanks,

Vinod.

Former Member
0 Kudos

As you have identified user-exit, I hope u r going to use MV45AFZZ.

You can try this..

Consider the case

You specify Factor as 10 and lenght as 1000. the Material has to be cut / split into 10 items of 1000 mts each. and the ITEMs table control should get 10 ITEMS .

There are two form routines available in that exit userexit_move_field_to_vbak and userexit_move_field_to_vbap.

In userexit_move_field_to_vbak, append those 9 item lines to XVBAP[] and in userexit_move_field_to_vbap modify that original item from 1000 to 10.

G@urav.

0 Kudos

Hi Gaurav,

yes I am using the exit MV45AFZZ . first i placed the code in

FORM USEREXIT_SAVE_DOCUMENT_PREPARE . it is populating the XVBAP table properly . i am able to see the changes in VBAP and VBEP tables also properly.

bold the main point is we have to pass on the values to XVBAP, IVBAP , XVBEP, AND IVBEP tables also. then only , the schedule lines will be also taken care of. bold

but i am not able to see the changes in the items table while in VA01 itself. after saving it . . . . . in VA02 i am able to see the changes.

So i tried to place it in FORM USEREXIT_MOVE_FIELD_TO_VBAK. even now i am not able to see the changes while i am in VA01. Is there any where we can place the code?

waiting for your replies.

Here is the code :

*************************************************************************************************************

FORM USEREXIT_MOVE_FIELD_TO_VBAK.

  • vbak-zzfield = xxxx-zzfield2.

*{ INSERT IMPK900044 1

*add line items to xvbap.

DATA: DA_CONFIGURATION1 LIKE CONF_OUT OCCURS 50 WITH HEADER LINE.

DATA: XVBAP_HIGH_POSNR LIKE VBAP-POSNR.

DATA: XVBEP_HIGH_POSNR LIKE VBEP-POSNR.

DATA : I_VBAP LIKE VBAP,

I_VBEP LIKE VBEP,

I_XVBAP LIKE XVBAP,

I_XVBEP LIKE XVBEP,

CHARI(1).

DATA : VA_ATWRT LIKE CONF_OUT-ATWRT,

VA_LENGTH LIKE CONF_OUT-ATWRT,

VA_TIMES(3),

VA_QTY(15) TYPE N.

IF SY-TCODE = 'VA01'.

IF RV45A-MUEBS EQ 'CABLE_CH'

AND FCODE = 'SICH'. "CHARACTERISTICS DISPLAY FIELD

CHECK NOT VBAP-CUOBJ IS INITIAL.

SVBAP-TABIX = 0.

SVBEP-TABIX = 0.

          • to get the Factor specified **************************************************

CALL FUNCTION 'VC_I_GET_CONFIGURATION_IBASE'

EXPORTING

INSTANCE = VBAP-CUOBJ

  • BUSINESS_OBJECT =

LANGUAGE = SY-LANGU

  • IV_INVALID_POSSIBLE = ' '

  • IV_NEUTRAL = ' '

TABLES

CONFIGURATION = DA_CONFIGURATION1

  • ET_CONF_WITH_AUTHOR =

  • EXCEPTIONS

  • INSTANCE_NOT_FOUND = 1

  • OTHERS = 2

.

IF SY-SUBRC = 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

READ TABLE DA_CONFIGURATION1 WITH KEY ATNAM = 'SAP_MILLCA_FACTOR'.

VA_ATWRT = DA_CONFIGURATION1-ATWRT.

READ TABLE DA_CONFIGURATION1 WITH KEY ATNAM = 'SAP_MILLCA_VBAP_KWMENG'.

VA_LENGTH = DA_CONFIGURATION1-ATWRT.

VA_QTY = VA_LENGTH.

CHARI = 'I'.

CLEAR : XVBAP,

IVBAP,

XVBEP,

IVBEP,

XVBAP_HIGH_POSNR,

SY-TABIX.

REFRESH : XVBAP,

IVBAP,

XVBEP,

IVBEP.

DO VA_ATWRT TIMES.

VA_TIMES = SY-INDEX.

  • To populate XVBAP and index table IVBAP.

MOVE VBAP TO I_VBAP.

MOVE-CORRESPONDING I_VBAP TO I_XVBAP.

I_XVBAP-POSNR = VA_TIMES * 10.

MOVE CHARI TO I_XVBAP-UPDKZ. "UPDATE INDICATOR

I_XVBAP-KWMENG = VA_QTY.

MOVE-CORRESPONDING I_XVBAP TO XVBAP.

APPEND XVBAP.

XVBAP_HIGH_POSNR = XVBAP-POSNR.

IVBAP-POSNR = XVBAP-POSNR.

IVBAP-TABIX = VA_TIMES.

APPEND IVBAP. "INDEX TABLE FOR VBAP.

*To populate XVBEP and the index table IVBEP.

MOVE VBEP TO I_VBEP.

MOVE-CORRESPONDING I_VBEP TO I_XVBEP.

I_XVBEP-POSNR = VA_TIMES * 10.

I_XVBEP-UPDKZ = 'I'.

I_XVBEP-WMENG = VA_QTY.

I_XVBEP-CMENG = VA_QTY.

I_XVBEP-BMENG = VA_QTY.

MOVE-CORRESPONDING I_XVBEP TO XVBEP.

APPEND XVBEP.

XVBEP_HIGH_POSNR = XVBEP-POSNR.

IVBEP-POSNR = XVBAP-POSNR .

IVBEP-TABIX = VA_TIMES .

APPEND IVBEP.

ENDDO.

ENDIF.

ENDIF.

ENDIF.

*} INSERT

ENDFORM.

0 Kudos

Hi Gaurav,

After i placed the code in FORM USEREXIT_MOVE_FIELD_TO_VBAK

and FORM USEREXIT_MOVE_FIELD_TO_VBAP , I am getting the following error:

No status object is available for SDI 0.

Object

number TM000000001VB (Message BS001)

What is this error ?

IS there a way to handle this?

Waiting for your replies.

Suki.

0 Kudos

Hi Sukhi,

I have a similar requirement , Please hel pme . Were u able to handle this, how did u handle it .

0 Kudos

Use USEREXIT_MOVE_FIELD_TO_VBAP in MV45AFzz.

Remeber to set update flag UPDKZ to I in vbap work area