cancel
Showing results for 
Search instead for 
Did you mean: 

How to prevent a printing of Delivery Return for Spcecific Sales order Type

former_member311223
Participant
0 Kudos

Hi All,

I have a requirement where Smartform needs to be created for delivery returns corresponding to few order types only (not for all order types). These few Sales Order ae saved in a Z-custom table.

I created a Routine 902 in VOFM under "Output Requirement" and based on the logic I am setting the SY-SUBRC field as 0 where the Output Type matches & setting SY-SUBRC = 4 where the Sales order types condition fails in the routine.

But still the Output types are getting saves for all Sales order types... even for those Sales order types that are not saved in the Z-custom table.

I have added the logic in both the subroutines available in the routine 902.

Kindly suggest where I am going wrong.

Logic.

READ TABLE t_constant WITH KEY value =lv_auart "Sales Order Type
BINARY SEARCH
TRANSPORTING NO FIELDS.
IF sy-subrc <> 0.
sy-subrc = 4.
ELSE.
sy-subrc = 0.
ENDIF.

Accepted Solutions (1)

Accepted Solutions (1)

former_member311223
Participant
0 Kudos

Hi All,

Thanks for the updates.

The logic which I wrote is correct. In the routine, based on the Sy-subrc value we can restrict the Output Type triggering. when I tested it with my FC, it was working properly. There was no issue, when the Delivery return is getting Created or Changes using VL01n & VL02N, this routine is getting called based on NACE configuration. In the routine I am checking the Sales Order type and based on our requirement I am setting the SY-SUBRC value. If SY-SUBRC = 0, Output Type is Triggered else it wont be triggered.

We don't need to debug NNAST or XNAST for this scenario.

Answers (2)

Answers (2)

VeselinaPeykova
Active Contributor

I am going to be really harsh here.

First, you have not explained the output type configuration. Initially, I thought that this is some delivery item output (V2), but after re-reading your question I wonder whether you are working on sales order output (V1).

Second - this cannot be your actual code, how do you expect that anyone without access to your system could tell you what you are doing wrong?

Third, since you are hardly sharing any details - what is preventing you from debugging the code (provided that the configuration and master data are correct, the routine is active and assigned)? Just place a break-point and start checking nnast, xnast, what is in the communication structures... It can't be that hard for a developer if functional consultants are capable of troubleshooting output determination.

former_member311223
Participant
0 Kudos

Hi Veselina,

My apologies.. if my post is confusing you..

First->This is related to delivery item output (V2), we are using the VL02N to trigger the output Type.

Second-> In the code I am fetching the delivery number from KOMKBV2-VBELN and getting the Sales order type from VBAK-AUART into LV_AUART. The selected Sales Order Types is fetched from customer table into the T_CONSTANT internal table. Then we are adding the below logic by reading the AUART using LV_AUART.

READ TABLE t_constant WITH KEY value =lv_auart "Sales Order Type
BINARY SEARCH
TRANSPORTING NO FIELDS.
IF sy-subrc <> 0.
sy-subrc = 4.
ELSE.
sy-subrc = 0.
ENDIF.

former_member311223
Participant
0 Kudos

Hi Veselina,

My apologies.. if my post is confusing you..

First->This is related to delivery item output (V2), we are using the VL02N to trigger the output Type.

Second-> In the code I am fetching the delivery number from KOMKBV2-VBELN and getting the Sales order type from VBAK-AUART into LV_AUART. The selected Sales Order Types is fetched from customer table into the T_CONSTANT internal table. Then we are adding the below logic by reading the AUART using LV_AUART.

READ TABLE t_constant WITH KEY value =lv_auart "Sales Order Type
BINARY SEARCH
TRANSPORTING NO FIELDS.
IF sy-subrc <> 0.
sy-subrc = 4.
ELSE.
sy-subrc = 0.
ENDIF.

Third-> The Routine is up & active. I have debugged the code and even referred the SDN links.

VeselinaPeykova
Active Contributor

If you have debugged the code I am surprised that you are unable to find the root cause.
Are you 100% sure that you are determining the correct sales order number and order type from the transactional data?
I am not a real developer, but the portions of your code do not make much sense to me (one reason could be my limited knowledge or that it is just a part of the actual logic).
What is the deal with this sy-subrc play? I don't see it used to update some variable that you use later for additional checks and if the documentation in notes (156230 - Requirements: What is permitted, what is not?) is correct, only sy-subrc = 0 as end result in a routine part (kobev, kobed) leads to proceeding with next steps (depends on where the routine is assigned), so why does it have to be set to 4 if it is not 0?
The decision by the functional consultant to use preceding document type to decide whether something needs to be printed for an item is rather strange - typically people use item categories or product groups to determine something like that.

Jelena
Active Contributor
0 Kudos

I agree. This is a simple debugging task. Look at the data and run every step through to make sure you're getting the right results. It's not that hard and if you are indeed an ABAP developer (or a developer) you should be able to do this without asking a question on SCN. If you're not a developer then get one. SCN is also not a replacement for the qualified resources.

The piece of code repeated many times here is not the whole "logic". Although BINARY SEARCH here seems to make no sense, an error might be in many other places here that you have not shared with us. Kindly make an effort on your own to troubleshoot this before returning to SCN with the same question. And refer to this blog on how to ask better questions.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Besides the fact that the above code makes no sense at all:

Never override system fields!!!

former_member311223
Participant
0 Kudos

Hi Horst,

Thank you for the update. But how can I achieve my requirement?