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: 

How to Update NAST-AENDE to X

former_member333737
Active Participant
0 Kudos

Hello Experts,

I have a scenario where we are sending shipment idocs from SAP when a shipment is created. When a inbound idoc is sent an output type is triggered an a idoc is sent from SAP. Whenever there is change in shipment for eg a date is changed another idoc gets triggered but the output type triggered  is not showing change. I want to change the NAST-AENDE flag to X when shipment 2 idoc is sent with any changes occur.

I am trying to write the code in FM06AEND or in the routine which I have created.

Your inputs will be highly appreciated.

Many Thanks,

Nikhil

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Nikhil,

It is classic scenario and SAP has a similar solution in Purchase Order Area ( Application EF ) for output type NEU. But SAP has got two process codes ME10 and ME11.

Program FM06AEND Routine CHANGE_FLAG should be good enough.

You can set up similar solution for your output type and make sure your Partner Profile has got two entries in the message control tab one having "Change Message" checkbox Ticked on and One is Not for your Process code SD11 or any custom one that you are using.

R

19 REPLIES 19

Former Member
0 Kudos

Hi Nikhil,

It is classic scenario and SAP has a similar solution in Purchase Order Area ( Application EF ) for output type NEU. But SAP has got two process codes ME10 and ME11.

Program FM06AEND Routine CHANGE_FLAG should be good enough.

You can set up similar solution for your output type and make sure your Partner Profile has got two entries in the message control tab one having "Change Message" checkbox Ticked on and One is Not for your Process code SD11 or any custom one that you are using.

R

0 Kudos

Hi Rudra,

I have done the same in partner profile one change message checkbox is ticked and the other not. Still not able to.

Thanks,

Nikhil

0 Kudos

Are you using the standard routine or the custom one? Also would you mind pasting the screenshot of your partner profile settings ( which includes) message control tab?

R

0 Kudos

I am using custom routine.

Also my code in routine is

 
CONSTANTS: lc_os21    TYPE shtyp VALUE 'OS21',

             lc_ot21    
TYPE shtyp VALUE 'OT21',
lc_zzincn 
TYPE zzincn VALUE 'RV61B953',

             lc_zzxkey2
TYPE  zzxkey VALUE 'CHECK'.

* Data declarations.

 
DATA: lv_vbeln TYPE vbeln,

  lv_subrc
TYPE sysubrc,

  lv_953  
TYPE char01,

  lv_953_re  
TYPE zzxkey.

 
DATA lv_tknum TYPE tknum.

 
DATA: l_nast_cmfpnr LIKE nast-cmfpnr,

        returncode  
LIKE sy-subrc,

        us_subrc
LIKE sy-subrc.

  lv_subrc
= 4.

 
SELECT COUNT(*) FROM zzxxv_check_tab

   
WHERE    zzincn =    lc_zzincn

   
AND      dcart  =    komkbv7-shtyp.                                "shipment type

 
SELECT SINGLE zzxkey1 FROM zzxxv_check_tab INTO lv_953_re

WHERE    zzincn =    lc_zzincn

AND    zzxkey2 = lc_zzxkey2.

 
IF sy-subrc = 0.

   
IF komkbv7-shtyp = lc_ot21.

* To check if OT21 is being called by OS21 for the second time or independently

     
CALL FUNCTION 'ZXXV_GET_SHIPMENT'

       
IMPORTING

          e_v_953
= lv_953.

     
IF lv_953 = ''.

       
IF *komkbv7-stdis = 'X'.

         
SELECT SINGLE vbeln FROM vttp INTO lv_vbeln

                
WHERE  tknum = *komkbv7-tknum.


         
IF sy-subrc = 0.

           
SELECT COUNT(*) FROM vttk AS a  INNER JOIN vttp AS b ON a~tknum = b~tknum

                  
WHERE b~vbeln = lv_vbeln AND

                         a
~shtyp = lc_os21.

           
IF sy-subrc = 0.

             
IF *komkbv7-dplbg NE komkbv7-dplbg.

                lv_subrc
= 0.

             
ENDIF.

           
ENDIF.

         
ENDIF.

       
ENDIF.

*  lv_subrc = 0. code commented by nikhilk

* code added by nikhilk

     
ELSE.

       
SELECT SINGLE zzxkey1 FROM zzxxv_check_tab INTO lv_953_re

       
WHERE    zzincn =    lc_zzincn

                
AND zzxkey2 = lc_zzxkey2.

       
IF lv_953_re EQ 'X'.

          lv_subrc
= 0.

         
UPDATE zzxxv_check_tab SET zzxkey1 = ''

                         
WHERE zzincn = lc_zzincn

                         
AND zzxkey2 = lc_zzxkey2.

* this will set the change flag so once this logic is triggered output type needs have change flag X


       
ELSE.

         
IF lv_953_re = 'Y'.

            lv_subrc
= 0.

           
UPDATE zzxxv_check_tab SET zzxkey1 = ''

               
WHERE zzincn = lc_zzincn

               
AND zzxkey2 = lc_zzxkey2.

         
ENDIF.

       
ENDIF. " * code added by nikhilk

     
ENDIF.

   
ELSEIF komkbv7-shtyp = lc_os21.
     
IF *komkbv7-tknum IS INITIAL.

       
SELECT SINGLE a~tknum INTO lv_tknum FROM vttk AS a  INNER JOIN vttp AS b ON a~tknum = b~tknum

       
WHERE b~vbeln = komkbv2-vbeln AND

              a
~shtyp = lc_ot21 AND

              a
~stdis = 'X'.

       
IF sy-subrc = 0.

          lv_subrc
= 0.

         
CALL FUNCTION 'ZXXV_SET_SHIPMENT'

           
EXPORTING

              i_v_953
= 'X'.
       
ENDIF.

       
SELECT SINGLE zzxkey1 FROM zzxxv_check_tab INTO lv_953_re

       
WHERE    zzincn =    lc_zzincn

       
AND    zzxkey2 = lc_zzxkey2.

       
UPDATE zzxxv_check_tab SET zzxkey1 = 'Y'

            
WHERE zzincn = lc_zzincn

            
AND zzxkey2 = lc_zzxkey2. "code added by nikhilk

     
ELSE.

       
SELECT SINGLE a~tknum INTO lv_tknum FROM vttk AS a  INNER JOIN vttp AS b ON a~tknum = b~tknum

              
WHERE b~vbeln = komkbv2-vbeln AND

               a
~shtyp = lc_ot21 AND

               a
~stdis = 'X'.

       
IF sy-subrc = 0.

         
IF ( *komkbv7-exti1 NE komkbv7-exti1 OR               "lwa_vttk1-exti1 OR

             *komkbv7
-exti2 NE komkbv7-exti2 OR                 "lwa_vttk1-exti2 OR

             *komkbv7
-tpbez NE komkbv7-tpbez OR                 "lwa_vttk1-tpbez OR

             *komkbv7
-dpabf NE komkbv7-dpabf OR                 "lwa_vttk1-dpabf OR

             *komkbv7
-dptbg NE komkbv7-dptbg OR                 "lwa_vttk1-dptbg OR

             *komkbv7
-dpten NE komkbv7-dpten OR                 "lwa_vttk1-dpten OR

             *komkbv7
-tdlnr NE komkbv7-tdlnr OR                 "lwa_vttk1-tdlnr OR

             *komkbv7
-zz_extra9 NE komkbv7-zz_extra9 OR         "lwa_vttk1-zz_extra9 OR

             *komkbv7
-zz_extra10 NE komkbv7-zz_extra10 ).       "lwa_vttk1-zz_extra10 ).

            lv_subrc
= 0.

           
CALL FUNCTION 'ZXXV_SET_SHIPMENT'

             
EXPORTING

                i_v_953
= 'X'.

         
ENDIF.

         
SELECT SINGLE zzxkey1 FROM zzxxv_check_tab INTO lv_953_re

                  
WHERE    zzincn =    lc_zzincn

               
AND    zzxkey2 = lc_zzxkey2.

         
UPDATE zzxxv_check_tab SET zzxkey1 = 'X'

              
WHERE zzincn = lc_zzincn

              
AND zzxkey2 = lc_zzxkey2. "* code added by nikhilk

       
ENDIF.

     
ENDIF.

   
ENDIF.

 
ENDIF.

  sy
-subrc = lv_subrc.

0 Kudos

Okay. Partner profile looks okay to me.

The coding wise : It is a too much of code.

Did you try debugging?

Concept is : If at the end of the routine SY-SUBRC EQ 0 then it is a change processing or else Initial processing.

R

0 Kudos

well yes the subrc eq 0 hence output type  gets triggered but not with the change flag. So is there something how can I set the change_flag eq 'X'

Thanks,

Nikhil

0 Kudos

Are you talking about Requirement routine? Because you say SY-SUBRC EQ 0 that is why output type gets triggered?

The Change routine has nothing to do with output triggering. It just sets the flag based on the SY-SUBRC value that's it.

I am sorry if you meant something else. But it worked for me.

0 Kudos

well not working for me the change flag doesn't get updated as the shipment idoc has been changed.


0 Kudos

Are you using Requirement routine?

Can you please confirm this?

I hope the output type is configured correctly with your program and routine.

0 Kudos

Hi Rudra,

Yes I am using requirement routine and its configured correctly with my program. I tried to manually update nast table in the code with aende eq X but idoc outbound doesn't trigger.

Any inputs.

Thanks & Regards

Nikhil

0 Kudos

Hi Nikhil,

For your purpose, using requirement routine is not a good Idea. Use the Change Output Program routine concept as I already mentioned similar to NEU output type. You can add use your own custom routine also and make sure SY-SUBRC = 0 at the end to consider that as a change output. See the code inside the standard routine as I highlighted below. You will have an idea.

R

0 Kudos

Hi Rudra,

Ok just to elaborate the exact requirement what we are doing.

Shipment 1 created by VT01N in SAP. It doesn't create an output type which is happening correctly.

Shipment 2 send by IDOC would have the delivery no created by 1st shipment and output type triggered which is happening correctly.

Now when shipment 2 send again with change data shipment 1 should be sent with CHA when output type is triggered.

Hope I have not made any confusions.

Many Thanks,

Nikhil


0 Kudos

Hi NIkhil,

I am sorry but I did not understand your requirement correctly.

Qsn :

Did you mean when shipment 2 to is sent with changed data via IDOC , you want to trigger the SHIPMENT One output but with Changed flag though no output has already triggered for Shipment 1? What is the link between the two shipments?

R

0 Kudos

Hi Rudra

Yes correct no output triggered for shipment 1 when created by vt01n the link is when shipment1 created it will be sent to warehouse with delivery and than inbound idoc with the same delivery will be sent output type triggered for shipment 2 and any further changes in the shipment another idoc will be sent and than output should trigger with change flag.

Thanks

Nikhil

0 Kudos

How you are sending Shipment 1 to warehouse in the first place?

Anyway it does not matter.

This is how you can approach.

1. When the second Idoc comes to change the shipment you should update some field in the Shipment which is not used. May be you can update a Header text but any unused field which is not used by business will be preferable.

2. Add a requirement routine to the output where you should check if the above mentioned field is populated or not and based on that you trigger the output. This is to ensure that the output is not triggered at the first place.


3. Now in the Change Output Program routine you can set the SY-SUBRC EQ 0 always to treat it as CHANGED output even for the first time.

R

0 Kudos

The 1st shipment is send by some background job..

Thanks for your inputs

Just to clarify when 2nd idoc is sent with the change I need to populate in the process code of inbound idoc

So when I find this populated field I trigger output type but how do I write code in change routine program

0 Kudos

You can find some standard field which is not used and then ask them to populate the idoc field so that you don't have to code. Or write some code in Exit.

For me if you are using the output type for this type of shipment only you can write a single statement


SY-SUBRC = 0. in your changed routine.



But I would suggest atleast create a maintainable custom table by sales area/Plant so the code can be switched off for different sales area /Plant in future.


Also if you are happy please close the thread so that others would know if this thread can be useful for them.




0 Kudos

Thanks mate for your inputs I will try this on Monday and let you know I don't think they will populate field in idoc may be in requirement routine I can update a field in vttk table for that shipment and in change program put sy-subrc eq 0.

I hope it would work.

0 Kudos

Ok Best of luck.

I will be on vacation for next two weeks. So won't be able to respond, if you have any.