I have been given the task to change the country of dispatch for Intrastat purposes depending on certian criteria. I was told to use EXIT:SAPLV50E_004.
Ok so what needs to be done!
1) I have entries in a customizing table that relate to which ekorg this exit applies to and which field should be updated (EIPO-VERLD), - This works fine
2) The function that should be called in SAPMM06E is Z_SET_CTY_OF_DISP_EIPO. - This is also called correctly when a break point is created the se37 in the exit.
3) First the function checks eine to see of there is a value in ZZVERLD (part of an append structure in EINE (field is maintainable in mm01 and mm02). If a value is present this should be used. if not....
4) Then a custom table needs to be checked /WUE/MM_INST_LOC, using the vendor number and ekorg as the key (along side mandant, this is maintainable is SM30). If no value is set then..
5) Do nothing, no intialisation as there could already be a value for EIPO-VERLD and this should then remain...
So I know the function is be called due debugging, what is wrong is the logic within the function.
Please see the code insert.
FORM z_set_cty_of_disp_eipo USING value TYPE any. DATA: lw_verld TYPE land1. SELECT SINGLE zzverld FROM eine INTO lw_verld WHERE infnr = ekpo-infnr AND ekorg = ekko-ekorg. IF sy-subrc = 0 AND NOT lw_verld IS INITIAL. MOVE lw_verld TO value. ELSEIF sy-subrc = 4.C SELECT SINGLE verld FROM /WUE/MM_INST_LOC INTO lw_verld WHERE ekorg = ekko-ekorg AND lifnr = ekko-lifnr. IF sy-subrc = 0 AND NOT lw_verld IS INITIAL. MOVE lw_verld TO value. ENDIF. ENDIF. ENDFORM.
The thing is, is that basically ekko and ekpo are empty, so the code returns a blank lw_verld as the first select ends fine I have to assume that it would just pull the first eine record it comes across, and this record has no ZZVERLD set.
What I really need is how can I get the relivant data that I can then pass to the select statements?
As I test I also checked the contents of eipo and that was also empty.
If I add
lw_verld = 'GB' MOVE lw_verld TO value
To the end of the function
This works and GB is set as the country of dispatch, so it is just access the PO data in the function that I am having a problem with.
If anyone can help that would be super.
Thanking everyone and anyone in advance.