BADI_SD_SALES_ITEM

Hi friends,
How to use BADI_SD_SALES_ITEM  to validate the fields.

Mahesh,
The BADI BADI_SD_SALES_ITEM is designed as internal BADI; the implementation can only be done, if the BADI is set to external. The property of a BADI is stored in the table sxs_attr. The flag internal must be cleared to use the BADI as external. The following short program will show you an example:
report z_xpra_upd_badi_def.
data: gt_prot type table of sprot_u,
gs_prot type sprot_u,
gv_simulate type xflag.
Constant Definitions for Protocoll:
constants:
gc_error_fatal value 'E', " Error message with stop_upgrade
gc_error value 'P', " Error message: no prod use!
gc_success value space, " Success
gc_info value space, " Info
gc_warning value 'W', " Warning
gc_lv_error type n value 2, " Level for type 'E'
gc_lv_add_error type n value 2, " Level for additional info
gc_lv_warning type n value 2, " This could be either 2 or 3
gc_lv_success type n value 3, " Success only at 3
gc_lv_info type n value 4, " Info-messages only at 3 or 4
gc_lv_debug type n value 4. " Additional info for yourself
start-of-selection.
gv_simulate = space.
perform bc_action using 'BADI_SD_SALES_ITEM'
gv_simulate.
Finally, the transport protocol will be added:
call function 'TR_APPEND_LOG'
tables
xmsg = gt_prot
exceptions
others = 5.
call function 'TR_FLUSH_LOG'.
END OF PROGRAM
*& Form bc_action
Function description/flow
Used global variables:
Read/Write
form bc_action using li_badi_def type sxs_attr-exit_name
li_simulate type xflag.
data: ls_sxs_attr type sxs_attr.
select single * into ls_sxs_attr
from sxs_attr client specified
where exit_name = li_badi_def.
if sy-subrc = 0.
if not ls_sxs_attr-internal is initial.
if gv_simulate is initial.
clear ls_sxs_attr-internal.
update sxs_attr client specified
from ls_sxs_attr.
endif.
if sy-subrc = 0.
perform bc_append_log using gc_lv_success
gc_success
'5@'
'000'
li_badi_def
text-001
sy-dbcnt
space.
else.
perform bc_append_log using gc_lv_error
gc_error
'5@'
'000'
li_badi_def
text-002
sy-subrc
space.
endif.
else.
perform bc_append_log using gc_lv_success
gc_success
'5@'
'000'
li_badi_def
text-003
space
space.
endif.
else.
perform bc_append_log using gc_lv_success
gc_success
'5@'
'000'
li_badi_def
text-004
space
space.
endif.
endform. "ACTION
*& Form bc_append_log
Function description/flow
Used global variables:
Read/Write
form bc_append_log using li_level type sprot_u-level " Level
li_severity type sprot_u-severity " Severity
li_ag type sprot_u-ag " Message-ID
li_msgnr type sprot_u-msgnr " Messagenumb
li_var1
li_var2
li_var3
li_var4.
clear gs_prot.
gs_prot-level = li_level.
gs_prot-severity = li_severity.
gs_prot-langu = sy-langu.
gs_prot-ag = li_ag.
gs_prot-msgnr = li_msgnr.
gs_prot-newobj = space.
gs_prot-var1 = li_var1.
gs_prot-var2 = li_var2.
gs_prot-var3 = li_var3.
gs_prot-var4 = li_var4.
append gs_prot to gt_prot.
endform. " bc_bc_append_log
This report can be used as XPRA run; for this you need to assign this report in a transport with property object type XPRA. After importing the transport the report will be started automatically.
Please handle this proposal solution carefully.
I found an approach for a solution; I'd like to provide you this solution in the following short summary:
Definition BADI_SD_SALES_ITEM, Method ITEM_PROCESS
• To set up the serial numbers to be assigned, first, you need a kind of buffer, in which the serial number get be transferred from outside to the function group 2032. I use the export/import memory function (export [parameter] from ti id 'MEMORY_NAME’) to get/set the serial numbers.
• Next, I read the already assigned serial numbers from the tables SER02 and OBJK.
• Then I merge the imported serial numbers with the actual serial numbers in DB to decide for deletions and inserts
• Based on the prior selected serial numbers I call the corresponding function modules to delete or insert the serial numbers (in buffer)
Process Serial Numbers (Deletion):
loop at lt_serial_no_ins assigning <serial_no>.
call function 'SERNR_DEL_FROM_AU'
exporting
sernr = <serial_no>-serial_no
material = fvbap-matnr
document = fvbap-vbeln
item = fvbap-posnr
importing
anzsn = fvbap-anzsn
serial_commit = lv_dataloss
exceptions
serialnumber_errors = 1
serialnumber_warnings = 2
others = 3.
endloop.
Process Serial Numbers (Inserts):
loop at lt_serial_no_ins assigning <serial_no>.
call function 'SERNR_ADD_TO_AU'
exporting
sernr = <serial_no>-serial_no
profile = fvbap-serail
material = fvbap-matnr
quantity = 1
cuobj = fvbap-cuobj
document = fvbap-vbeln
item = fvbap-posnr
debitor = ls_vbak-kunnr
vbtyp = ls_vbak-vbtyp
sd_auart = ls_vbak-auart
sd_postyp = fvbap-pstyv
importing
anzsn = fvbap-anzsn
serial_commit = lv_dataloss
exceptions
konfigurations_error = 1
serialnumber_errors = 2
serialnumber_warnings = 3
others = 4.
emdloop.
• After this all the serial numbers are stored in the buffer of function group IPW1
• Next, the stored serial numbers in IPW1 will be posted by the post process, this will be done also by a BadI (see Next)
Definition BADI_SD_SALES, Method SAVE_DOCUMENT
Using Check Handling with Operation SDAP for Update:
call function 'SERIALPROFILE_CHECK'
exporting
operation = 'SDAP'
tables
tab_cuobj = lt_dbcuobj.
To use the above mentioned BadIs, you have to consider the following:
• The Badis are provided with package VA_BADI
• This BadIs are all internally
• To use / create a implementation you have to set the internal to external (Table SXS_ATTR, Field INTERNAL)
• The best way is to write a report, in which the flag will be set for definite BadIs, so this report can be link as XPRA in the transport request; for this you have to set the following additional entry in the transport request:
R3TR XPRA Z_GEMINI_XPRA_UPD_BADI_DEF
Don't forget toreward if useful.

Similar Messages

  • How to create implementation for BADI BADI_SD_SALES_ITEM

    Hi all,
    When i try to create a implementation for BADI it erorrs out saying "its for intenal use". Is there any way i can still go ahead and create a implementation for this BADI BADI_SD_SALES_ITEM.
    Thanks in advance.

    Hello Jayakumar,
    The BADI <b>BADI_SD_SALES_ITEM</b> is designed as internal BADI; the implementation can only be done, if the BADI is set to external.  The property of a BADI is stored in the table <b>sxs_attr</b>. The flag <b>internal</b> must be cleared to use the BADI as external. The following short program will show you an example:
    report  z_xpra_upd_badi_def.
    data: gt_prot          type table of sprot_u,
          gs_prot          type sprot_u,
          gv_simulate      type xflag.
    * Constant Definitions for Protocoll:
    constants:
          gc_error_fatal   value 'E',      " Error message with stop_upgrade
          gc_error         value 'P',      " Error message: no prod use!
          gc_success       value space,    " Success
          gc_info          value space,    " Info
          gc_warning       value 'W',      " Warning
          gc_lv_error      type n value 2, " Level for type 'E'
          gc_lv_add_error  type n value 2, " Level for additional info
          gc_lv_warning    type n value 2, " This could be either 2 or 3
          gc_lv_success    type n value 3, " Success only at 3
          gc_lv_info       type n value 4, " Info-messages only at 3 or 4
          gc_lv_debug      type n value 4. " Additional info for yourself
    start-of-selection.
      gv_simulate = space.
      perform bc_action using 'BADI_SD_SALES_ITEM'
                               gv_simulate.
    * Finally, the transport protocol will be added:
      call function 'TR_APPEND_LOG'
        tables
          xmsg   = gt_prot
        exceptions
          others = 5.
      call function 'TR_FLUSH_LOG'.
    * END OF PROGRAM
    *&      Form  bc_action
    *       Function description/flow
    *       Used global variables:
    *       Read/Write
    form bc_action using li_badi_def   type sxs_attr-exit_name
                         li_simulate   type xflag.
      data: ls_sxs_attr type sxs_attr.
      select single * into ls_sxs_attr
             from sxs_attr client specified
             where exit_name = li_badi_def.
      if sy-subrc = 0.
        if not ls_sxs_attr-internal is initial.
          if gv_simulate is initial.
            clear ls_sxs_attr-internal.
            update sxs_attr client specified
            from ls_sxs_attr.
          endif.
          if sy-subrc = 0.
            perform bc_append_log using gc_lv_success
                                        gc_success
                                       '5@'
                                       '000'
                                        li_badi_def
                                        text-001
                                        sy-dbcnt
                                        space.
          else.
            perform bc_append_log using gc_lv_error
                                        gc_error
                                       '5@'
                                       '000'
                                        li_badi_def
                                        text-002
                                        sy-subrc
                                        space.
          endif.
        else.
          perform bc_append_log using gc_lv_success
                                      gc_success
                                     '5@'
                                     '000'
                                      li_badi_def
                                      text-003
                                      space
                                      space.
        endif.
      else.
        perform bc_append_log using gc_lv_success
                                    gc_success
                                   '5@'
                                   '000'
                                    li_badi_def
                                    text-004
                                    space
                                    space.
      endif.
    endform.                    "ACTION
    *&      Form  bc_append_log
    *       Function description/flow
    *       Used global variables:
    *       Read/Write
    form bc_append_log using li_level    type sprot_u-level    " Level
                             li_severity type sprot_u-severity " Severity
                             li_ag       type sprot_u-ag       " Message-ID
                             li_msgnr    type sprot_u-msgnr    " Messagenumb
                             li_var1
                             li_var2
                             li_var3
                             li_var4.
      clear gs_prot.
      gs_prot-level    = li_level.
      gs_prot-severity = li_severity.
      gs_prot-langu    = sy-langu.
      gs_prot-ag       = li_ag.
      gs_prot-msgnr    = li_msgnr.
      gs_prot-newobj   = space.
      gs_prot-var1     = li_var1.
      gs_prot-var2     = li_var2.
      gs_prot-var3     = li_var3.
      gs_prot-var4     = li_var4.
      append gs_prot to gt_prot.
    endform.                    " bc_bc_append_log
    This report can be used as <b>XPRA</b> run; for this you need to assign this report in a transport with property object type <b>XPRA</b>. After importing the transport the report will be started automatically.
    Please handle this proposal solution carefully.
    Best regards,
    Kurt.

  • BAdI definition BADI_SD_SALES_ITEM is only provided for SAP internal use

    I tried to create an implementation for the BADI  BADI_SD_SALES_ITEM   . It gave the following error message  .
    <u><b>BAdI definition BADI_SD_SALES_ITEM is only provided for SAP internal use</b></u>
    What does this message  mean?
    I want to use the method ITEM_CHECK   in this BADI   .is there a way to write a code in this method by creating an implementation for this BADI.

    Hi
    It means that BADI can be used only by SAP, i.e. it can be used only on the original SAP system, so not in a customer system as yours.
    See the table SXS_ATTR, here you can find the attributes of the BADI, in particular you can see the flag FOR ONLY INTERNAL USE.
    If this flag is active and the system isn't a SAP system, that error'll occur.
    Max

  • BADI_SD_SALES_ITEM  is only provided for SAP Internal Use

    Hi,
    I am trying to implement this BADI_SD_SALES_ITEM but appears with the text 'BADI definition BADI_SD_SALES_ITEM is only provided for SAP internal use' . Can you tell me what should i change credit limit o Can you tell me how use  this BADI_SD_SALES_ITEM  ?
    Diana

    Hi Diana,
    On 4.7 at least, it is not released for external use by customers..  There is a SAP note out there that says the same thing -- and tells you to use the standard exits (eg. MV45AFZZ)
    Guess SAP created it in case they need to enhance the standard, and they don't want us to touch it yet.

  • VA01, message when save a sales order

    Hi,
    I need to validate each one of the amounts of each position of an order of sales, this validation must allow that when finding an error shows the message and leaves to the user the possibility of modifying the amount with error, this validation only must become at the time of saving the order.
    I have proven several alternatives with userexit_save_document and badi_sd_sales_item in the method item_check, but it does not use it because the amounts are valued always and I only need that it is validated when is going to save it. Please if somebody can give some idea. 
    Thanks,
    Claudia

    Hi,
    I use the user exit save_document_prepare and already shows the message but me it leaves disabled the positions and  I cannot modify them, when changing the message class it shows the message but at the same time save the sales order, i need that when find an error show the message and i can modify this position before save the sales order. 
    Thanks,
    Claudia

  • How to make field mandatory in Sales Order Item level?

    Hi SDN's,
    I need to make Shipping type field(Item level) mandatory in Sales order.
    Can any one tell me what is the user-exit to achieve this?
    Thanks in advance..
    Regards,
    Rahul

    Rahul,
    U can check the BADI     'BADI_SD_SALES_ITEM'
    othewise u can check
    Exit Program MV45AFZZ.
    Check the program SAPMV45A
    V45W0001
    V46H0001

  • Restrict Item Category Item Creation using Reference Only

    Hi All
    Here is the scenario, I want  "Restrict Item Category Item Creation using Reference Only"
    a.Retrieve document number VBELN from sales order header table VBAK for the current order. Check if the sales order is of type ‘ZAB’ referencing field AUART in table VBAK.
    note : Any changes to existing sales order "ZAB" will be performed in thesame sales order type(ZAB) in VA02 transaction.
    b.If step a is passed, check internal table structure for sales order item level as XVBAP-PSTYV for possible item category values of 'ZDEF' for the entered line item and document number (XVBAP-VBELN).
    c.If the cancel/change item category values are found on the line item, check internal table structure for document flow (XVBFA) if the cancel/change item category was created as reference:
    i.Check if entry exists in XVBFA for the preceding document number field VBELV with value equal to value in the subsequent document number field VBELN. This value must equal the current sales document number VBELN in table VBAK.
    ii.The above check must be done in conjunction with the following check:
                1.Check if entry exists in XVBFA for the preceding document type field VBTYP_V with value ‘C’ equals subsequent document type field VBTYP_N with value of ‘C’.
    d.Once the above checks are passed, collect the item number from internal table XVBAP (Field: POSNR) for the change/cancel item category line item added to the sales order.
    e.Check if the item number retrieved in the previous step exists in table VBAP (Field: POSNR) with an item category that is not part of the list of cancel/change item category defined in step b.
    f. Check if the item number collected in the previous step exists in the subsequent item number (Field : POSNN) in internal table XVBFA for the row that passed checks in steps b and c.
    g.If item number exists, check if this subsequent item number field equals the preceding item number field value (Field: POSNV) in table XVBFA.
    h.If step g fails, generate an error message stating that the user needs to the create the cancel/change item category line item with reference to the original line item and do not allow the user to proceed with the transaction.
    i.If step g succeeds, allow the user to proceed with the transaction.
    can any one send me the logic for this scenario.
    Rgds
    Chinna

    Hi Chinna,
      Please use BADI "BADI_SD_SALES_ITEM" to achieve your requirement..
      Let me know if you have further questions..
    BR
    Rakesh

  • User Exit for changing RBKP-BVTYP in t-Code MRRL

    Hi ,
    We have to change Partner bank type field (RBKP-BVTYP) while creating invoice through t-code MRRL. i tried to find out the user exit or BADI for this
    purpose, but i could not.
    i found below user exits and badi but here i was unable to change the value. there were other exits but there also it was not possible to change the value.
    Enhancement MRMH0001 - component - EXIT_SAPLMRMH_001 and EXIT_SAPLMRMH_002
    here only limited change to RBKP is permitted.
    I tried with BADI INVOICE_UPDATE but it is not allowed there also.
    Can we do it with some configuration or substitution rule ?  if yes then how?
    thnaks in advance
    rajpal

    Hi Emir,
    BADI BADI_SD_SALES_ITEM now changed to enhancement spot.
    In SE18: enter Enhancement spot - BADI_SD_SALES_ITEM.
    Inside enhancement spot BADI_SD_SALES_ITEM four BADI definition were exist.
    I think BADI definition MSR_SD_SALES is use full for you (This BADI definition is not reserver for SAP intrnal use.
    And above enhancement spot also not reserverd for sap internal use.
    Just try to implementation BADI definition MSR_SD_SALES and use method CHANGE_BILLING_BLOCK_ITEM.
    BR,
    Vijay

  • Adding an extra line item in completed sales order

    Dear Friends
    We have a requirement that a sales order say order no 1000 with material A qty 5 units
    This order is Delivered---Billed 
    The requirement 1 is no one should change the qty to more than 5 units
    This i can control through OVAH message settings from warning to error
    The requirement 2 is no one should add material B or material C in that order 1000
    No other material should be added
    This i think has to be done through some userexit
    Expecting your valuable inputs on this issue mainly the requirement 2 the suitable exit
    Regards
    Raja

    HI,
    Perhaps you can try with USEREXIT_CHECK_VBAP in report MV45AFZB.
    Other possibilty is the BADI BADI_SD_SALES_ITEM, where the method ITEM_CHECK.
    Perhaps the most powerful is userexit_save_document in report MV45AFZZ, but it works when you save the document. Here you can compare XVBAP (with the new item will have the field UPDKZ = 'I') with YVBAP (you can compare the line items of both internal tables). Finally, you can use the status of deliveried and billed of XVBUP, YVBUP, XVBUK, YVBUK to do the final checks.
    Perhaps you can fix warning messages in the first exits (in dialog) and in the saving event set the error message.
    Set the break point and check the data in these structures, and think in the right algorithm.
    I hope this helps you
    Regards,
    Eduardo

  • Ship-to Party is not maintained in sales area

    Hi,
    While creating a sales order for a company code and if we give a different ship-to party, which is not belongs to that sales area, I'm getting a message "Ship-to Part XXX is not maintained in sales area abc xxxx yy zz".
    When I tried to add one more partner at header level, say "Mark for customer", and give the different customer number, the error is not coming.
    Can anyone tell whether this check will be done only for standard partners like Sold-to, Ship-to etc? and not for custom partners?
    Thanks,
    Kishore

    Try the following:
    BADI_SD_SALES        General Enhancements for Sales Order Proces
    BADI_SD_SALES_ADDON  Special enhancements which are not universa
    BADI_SD_SALES_BASIC  Enhancements for Sales Order Processing Par
    BADI_SD_SALES_ITEM   Enhancements for Sales Order Processing (It
    Andrew

  • Add new line in VA01

    hi
    I want to add a new line in va01 when a condition is requested. So for example i put 3 line and when a condition is ok i want to create so insert in vbap a new line in the order. I try with  the badi BADI_SD_SALES_ITEM and ITEM_PREPARE but it's not work . Any idea ??
    thanks

    hI,
    The badi BADI_SD_SALES_ITEM is the purpose of SAP Internal use (Check the Checkbox in Attributes Tab)so u can't implement the BADI.
    try to keep the code even in USEREXIT_SAVE_DOCUMENT/USEREXIT_CHECK_VBAP in MV45AFZB.check the theard
    Re: add a new tab in transaction ME51N
    Regards
    Kiran Sure
    Edited by: Kiran Sure(skk) on May 20, 2008 5:19 PM

  • BADI for PM Order data change

    Dear all,
    In one of our requirements, we need to update the data present on the CAUFVD structure before AUFK is updated.
    There is an existing Z bespoke field on the table AUFK added through an include. As a part of the Order creation, this field remains empty and is generally filled in through a workflow that runs after the order is saved.
    The requirement now is to update this field as a part of the Order creation process and it has to be calculated using a Function Module.
    I was trying to see if we can use WORKORDER_UPDATE BADI for this purpose, but seems like this BADI doesn't allow users to Modify/Update the contents of CAUFVD structure. And we haven't found any user exits for the same purpose.
    Is there any way I can update the Z field on the CAUFVD structure through a BADI or an User Exit please?
    Warm regards,
    Vijay.

    Hi,
    After upgardeecc5.0 to ecc 6.0  BADI_SD_SALES_ITEM badi is migrated to spot with same name,so now this spot not working and its saying SAP internal use,but in ecc5.0 we have a code its not effecting on ecc6.0.
    Please help on this .
    Regards
    Mahesh

  • Adding an extra screen field in CJ88

    Hi,
    The FICO consultant wants to know whether we can add an extra screen field in CJ88.He wants to add the posting year.Currently there is facility to add posting period and the posting year will be same as the fiscal.He wants to change the posting year.Due to this he wants to add an extra screen field - posting year so that the user can change it during reversal.
    If yes then how it is bo done.
    If not, is it possible to copy the entire CJ88 code and make zprogram and ztcode and add this extra field.
    Please let me know your suggestion.
    Thanks,
    Rajani

    HI,
    Perhaps you can try with USEREXIT_CHECK_VBAP in report MV45AFZB.
    Other possibilty is the BADI BADI_SD_SALES_ITEM, where the method ITEM_CHECK.
    Perhaps the most powerful is userexit_save_document in report MV45AFZZ, but it works when you save the document. Here you can compare XVBAP (with the new item will have the field UPDKZ = 'I') with YVBAP (you can compare the line items of both internal tables). Finally, you can use the status of deliveried and billed of XVBUP, YVBUP, XVBUK, YVBUK to do the final checks.
    Perhaps you can fix warning messages in the first exits (in dialog) and in the saving event set the error message.
    Set the break point and check the data in these structures, and think in the right algorithm.
    I hope this helps you
    Regards,
    Eduardo

  • Additional tab in VA02

    Hi guys,
    Is it possible to add a new tab in VA02?
    I've managed to add fields to 'Additional data B' with screen exits 8309 and 8459, but unfortunately that's not the way they want it...
    Is there a BAdI or another user exit which provides me this functionality?
    I only found BADI_SD_SALES, BADI_SD_SALES_BASIC and BADI_SD_SALES_ITEM,but I didn't see how I coan add the tab there.
    Furthermore there're are the BAdIs BADI_SD_TAB_CUST_H and BADI_SD_TAB_CUST_I, but they're for internal use only...
    Thanks and regards,
    Eddie.

    why do I always ask questions that nobody is able to answer???
    Ok, nobody can answer my first question...
    So, does at least anybody know how to change the title of the tab 'Additional data B' in program SAPMV45A
    First try to post in the right forum to get right direction.  Posting in a wrong forum is your mistake.  Don't blame SCN members when the mistake is yours and avoid commenting as above.  Anyway, moved from SAP ERP Sales and Distribution (SAP SD) to ABAP Development
    G. Lakshmipathi

  • Problem in implemntation of badi

    hello!
    we are in ecc6 and we want to implement badi ME_MEREQ_PARKING, using SE19, and we recieve the following error badi definition ME_MEREQ_PARKING is only provided for sap internal use.
    how can we implement new badi in ECC6?
    regards
    yifat

    Hi Yifat,
    Refer the links,
    BAdI definition BADI_SD_SALES_ITEM is only provided for SAP internal use
    BAdI definition for SAP internal use
    Hope this helps..
    Regards,
    Hema.
    Reward points if it is useful.

Maybe you are looking for

  • Gaps in-between  livepaint shapes when saving to PDF

    Im using CS6 and when saving to PDF my live paint objects have a slight gap inbetween the shapes in the live paint object. They do not appeare in the illustrator file or when saved as jpeg, png, etc only PDFs. I have been using Illustrator for a coup

  • Pearl 8120 and 8130

    Hi, I have two questions: 1. Blackberry Pearl 8130 dont have edge, then is it far to say that its the email downloading will be slow then Pearl 8120? 2. I see videos of Pearl 8120 and the display is colored but on the website I found that color displ

  • Replace CASE with DECODE

    Guys, I want to replace CASE statement with DECODE. How ? case when msg.is_swap = 'Y' and msg.buy_sell = 1 then 'SO' when msg.is_swap = 'Y' and msg.buy_sell = 0 then 'SI' else '' end As TransactionType How should i implement DECODE function to do the

  • Everytime I try and restore my ipod on itunes it says error 2003, what do i do?

    everytim i try and restore my ipod on itunes, it tells me error 2003, ive had this ipod for over a year now ad this has ever happen. i have no clue how to fix it any suggestions?

  • ALV interactive + normal list

    Hi All, I need some help regarding to  my requirement. I do have ALV developed using classes. When  i click a button on the alv, a normal list (using write statements) has to be displayed. When i do this, still alv is displayed and when i click the b