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: 

Use of Exit 'EXIT_SAPLV09A_004' or smod 'V09A0004'

Former Member
0 Kudos

Hey Everyone,

We have a scenario whereby a user may need to change the sold-to party on a sales order. However, the sales order already has a manually entered and modified partner on it of type 'ZT'. As you likely know, when you change the sold-to partner on a sales document you redetermine all the partners and the manually entered partner goes away. We would like to always keep the 'ZT' partner. The configuration is complete in VOPA for this partner such that user exits V09A0004 and V09A0003 are triggered when they are active. User exit V09A0003 does not have the table output that I would need to keep the manual entries, but V09A0004 does. So, I've put the very simple code below into the exit and it works great...however, the sales document has the original customer master address on it and not the one I just read from ADRC. I have to believe that it is possible for me to affect the address of the partner irrespective of what is on the customer master because these fields are provided for me...why else would stras, name1, city1 and etc be on the frt_determinated_partners table? I've searched for a flag or something, but to no avail...any input would be greatly appreciated.

No...I have not tried the mv45af** exits yet. I was hoping to do this in the enhancement for partner determination provided.

Thanks,

Greg

TYPES: BEGIN OF ty_adrc.

INCLUDE STRUCTURE adrc.

TYPES: END OF ty_adrc.

DATA: para TYPE tpara-paramid VALUE 'AUN',

lv_vbeln TYPE vbeln,

lv_kunnr TYPE kunnr,

lv_adrnr TYPE adrnr,

lt_adrc TYPE TABLE OF ty_adrc,

wa_adrc LIKE LINE OF lt_adrc,

wa_sdpartner_enhanced_kupav TYPE sdpartner_enhanced_kupav.

GET PARAMETER ID para FIELD lv_vbeln.

SELECT SINGLE adrnr kunnr INTO (lv_adrnr, lv_kunnr) FROM vbpa

WHERE vbeln = lv_vbeln

AND parvw = 'ZT'.

IF sy-subrc = 0.

SELECT SINGLE * INTO wa_adrc FROM adrc

WHERE addrnumber = lv_adrnr.

IF sy-subrc = 0.

wa_sdpartner_enhanced_kupav-defpa = 'X'.

wa_sdpartner_enhanced_kupav-kunnr = lv_kunnr.

wa_sdpartner_enhanced_kupav-vkorg = fif_vkorg.

wa_sdpartner_enhanced_kupav-vtweg = fif_vtweg.

wa_sdpartner_enhanced_kupav-spart = fif_spart.

wa_sdpartner_enhanced_kupav-parvw = 'ZT'.

wa_sdpartner_enhanced_kupav-parza = '000'.

wa_sdpartner_enhanced_kupav-kunn2 = lv_kunnr.

wa_sdpartner_enhanced_kupav-adrnr = lv_adrnr.

wa_sdpartner_enhanced_kupav-name1 = wa_adrc-name1.

wa_sdpartner_enhanced_kupav-name2 = wa_adrc-name2.

wa_sdpartner_enhanced_kupav-ort01 = wa_adrc-city1.

wa_sdpartner_enhanced_kupav-pstlz = wa_adrc-post_code1.

wa_sdpartner_enhanced_kupav-regio = wa_adrc-region.

wa_sdpartner_enhanced_kupav-spras = wa_adrc-langu.

wa_sdpartner_enhanced_kupav-telf1 = wa_adrc-tel_number.

wa_sdpartner_enhanced_kupav-stras = wa_adrc-street.

wa_sdpartner_enhanced_kupav-land1 = wa_adrc-country.

wa_sdpartner_enhanced_kupav-ktokd = 'Z002'.

wa_sdpartner_enhanced_kupav-address_type = '1'.

MOVE-CORRESPONDING wa_adrc TO wa_sdpartner_enhanced_kupav.

APPEND wa_sdpartner_enhanced_kupav TO frt_determinated_partners.

ENDIF.

ENDIF.

3 REPLIES 3

valter_oliveira
Active Contributor
0 Kudos

Hi there.

Is 'ZT' a header partner in your document? When you make that append, I suppose that itab frt_determinated_partners will have two partners 'ZT' (unless it's empty at the begining) and if it is in the same posnr is not possible (header posnr = '000000'). Perhaps this exit is called several times, one determination of partners for each position (header and items)?

Also check what is field SELKZ. The call of the exit is:


CALL FUNCTION 'EXIT_SAPLV09A_004'
            EXPORTING
              FIF_VKORG                 = VTCOM-VKORG
              FIF_VTWEG                 = VTCOM-VTWEG
              FIF_SPART                 = VTCOM-SPART
              FIF_OBJECTTYPE            = LVF_OBJECTTYPE
              FIF_PROCESSMODE           = GV_PROCESSMODE
            TABLES
              FRT_DETERMINATED_PARTNERS = PA.

and after that you find:


READ TABLE PA WITH KEY SELKZ = 'X'.
IF SY-SUBRC < 4.
  MOVE-CORRESPONDING PA TO KUPAV.
ELSE.
  CLEAR KUPAV.
ENDIF.

So, give it a try to selkz = 'X'.

Regards.

Valter Oliveira.

0 Kudos

Thanks Valter,

I have tried this flag already (I should have commented on that in the post). I noticed that selkz has three options...

' ' Not selected

* Selected and processed

X Selected but not yet processed

all of which I tried to no avail.

Thanks again,

Greg

0 Kudos

I was not able to find a way to apply a one-time customer address within either of the two exits mentioned earlier. However, sometimes I have a tendency to make things harder than they truly are and once I stepped away from this one it seemed apparent that I could do everything I wanted within the MV45AF* exits. The very simple code is below that solves my problem within the MV45AFZB exit in the form USEREXIT_CHECK_VBAK. In short, it says...if the order has a 'ZT' partner function on it write that partner function to a memoryid unique to the user. If at any time this exit is hit and the 'ZT' has been removed...well, put it back on. Simple.

IF t180-trtyp <> 'A'.

IF xvbak-auart = 'ZFG' OR xvbak-auart = 'ZIN'.

DATA: lt_vbpa LIKE vbpa, lt_kupav LIKE kupav,

wa_xvbpa LIKE LINE OF xvbpa,

memoryid(15) TYPE c.

CONCATENATE 'XVBPA' sy-uname INTO memoryid.

READ TABLE xvbpa WITH KEY parvw = 'ZT' INTO wa_xvbpa.

IF NOT sy-subrc = 0.

IMPORT wa_xvbpa FROM MEMORY ID memoryid.

IF sy-subrc = 0.

wa_xvbpa-updkz = 'I'.

APPEND wa_xvbpa TO xvbpa.

FREE MEMORY ID memoryid.

ENDIF.

ELSE.

EXPORT wa_xvbpa TO MEMORY ID memoryid.

ENDIF.

ENDIF.

ENDIF.