2014 Sep 23 6:56 PM
Hello experts,
I have a tricky requirement from my client and was wondering if I could get some help.
My requirement is to create a program that rejects or deletes documents based on a selection screen. The documents could be a sales order, a shipment or a delivery... so far, so good, no big deal.
The client also wants me to RE-PRINT the respective form (sales order, pick list, bill of landing, etc) exactly the same way as it was printed when created, but with the header that says CANCELLED.
I am debating on the best way to do this... if I should make copies of the forms, or try to re-print them from the different program and create a condition for the new header to be printed...
I am opened to suggestions...
Anyone has ever done something like this?
Any ideas are appreciated!
Thanks,
Fernanda
2014 Sep 30 11:26 PM
Ok guys...
This is how this worked:
* Find record in NAST table to reprint - I already had the delivery number so I pick up the info in NAST first
SELECT SINGLE *
FROM NAST
WHERE KAPPL = 'V2'
AND OBJKY = v_delivery.
* AND ( KSCHL = 'ZLPP' OR
* KSCHL = 'ZLBP' ).
*Then go to TNAPR to get the form / program info
IF sy-subrc IS INITIAL.
SELECT SINGLE *
FROM tnapr
WHERE kschl = nast-kschl
AND nacha = nast-nacha
AND kappl = nast-kappl.
ENDIF.
PERFORM (tnapr-ronam) IN PROGRAM (tnapr-pgnam) USING ret_code us_screen IF FOUND.
So this becomes a generic code to print any form.
This made the first print of the form to be re-printed.
I only need to make the changes in the form now but this is all good! YAY!
Thanks for the help! 🙂
2014 Sep 24 4:24 AM
Hello Fernanda,
Please follow below approach to reprint sales order. Hope it helps you.
1. Check NAST table if the message type exists when sales order was created.
2. If entry exist, reprint sales order by using program SD70AV1A.
3. use submit statement for program SD70AV1A to reprint sales order .
4. Export a variable(lv_cancel) to memory in your main program .
5.In driver program of that particular condition type, import this variable((lv_cancel)).
6.Write a condition in Header Window of Form .
/: If lv_cancel = 'X'
/: &CANCELLED&
/: ELSE
/: &ORIGINAL&.
/:ENDIF.
To reprint delivery ,use transaction VL71(SD70AV2A).
Thanks
2014 Sep 25 4:44 PM
Thank you so much for your answer!
I'll try that and see how it goes! I'll mark you as helpful for now! 'Cause it sure helped!
2014 Sep 25 4:53 PM
Hello Fernanda,
Thanks for such wonderful words and do let us know the outcome .
2014 Sep 25 4:55 PM
Hi
That's is a good solution, you can also think other solution, but I believe the logic will alwyas the same suggested by Always Learner
Well but there's or could be a big (or little) problem you should speak about your customer:
It's not possible to repeat the same print
The print programs get the data to be printed from master data, documents,...and so....and you can't ensure these data will be always the same.
The only solution can ensure to repeat the same print in every time is the archiving
Max
2014 Sep 25 5:00 PM
That's definitely something to consider Max.
What I'm suggesting (with Always Learner approach) is to re-print whatever was printed LAST. If there were changes, the document will reflect the changes... I think the customer understands that!
I'll be working on the logic today or tomorrow but will only be able to test it next week!
I'll keep you guys posted!
2014 Sep 30 11:26 PM
Ok guys...
This is how this worked:
* Find record in NAST table to reprint - I already had the delivery number so I pick up the info in NAST first
SELECT SINGLE *
FROM NAST
WHERE KAPPL = 'V2'
AND OBJKY = v_delivery.
* AND ( KSCHL = 'ZLPP' OR
* KSCHL = 'ZLBP' ).
*Then go to TNAPR to get the form / program info
IF sy-subrc IS INITIAL.
SELECT SINGLE *
FROM tnapr
WHERE kschl = nast-kschl
AND nacha = nast-nacha
AND kappl = nast-kappl.
ENDIF.
PERFORM (tnapr-ronam) IN PROGRAM (tnapr-pgnam) USING ret_code us_screen IF FOUND.
So this becomes a generic code to print any form.
This made the first print of the form to be re-printed.
I only need to make the changes in the form now but this is all good! YAY!
Thanks for the help! 🙂
2014 Oct 01 9:35 AM
Hi
Sorry but if you want to use that solution, why don't you use standard report RSNAST00?
Max
2014 Oct 01 2:00 PM
2014 Oct 01 2:19 PM
2014 Oct 01 2:23 PM
I meant the requirement I had to develop...
It does other things... not only just re-print the forms!
Thanks!
2014 Oct 01 2:45 PM
Hi
Yes I know, It's just only a exchange of points of view,
but if I need to re-print a logistic document, I would call RSNAST00 without to replace the code:
submit rsnast00
with p_again = 'X'
with s_kappl = 'V2'
with s_nacha = '1'
with s_objky = v_delivery and return.
Now the standard program does what you need
Max
2014 Oct 01 2:50 PM
Great, thanks!!
Seems like it's pretty much the same thing!
I'll change if it doesn't work completly!
2014 Oct 01 3:22 PM
You do the same thing RSNAST00 does, so it'll work
but if the delivery has several messages, it should be better to use NACHA in the selection in order to get the print only:
SELECT SINGLE *
FROM NAST
WHERE KAPPL = 'V2'
AND OBJKY = v_delivery.
AND NACHA = '1'
* AND ( KSCHL = 'ZLPP' OR
* KSCHL = 'ZLBP' ).
The second question is you don't check if the delivery was printed before, I've understood you need to re-print a document, here you can print delivery not printed yet.
If you need to check it, you should use VSTAT in your selection too:
SELECT SINGLE *
FROM NAST
WHERE KAPPL = 'V2'
AND OBJKY = v_delivery.
AND NACHA = '1'
AND VSTAT = '1'
* AND ( KSCHL = 'ZLPP' OR
* KSCHL = 'ZLBP' ).
These are main differences between your solution and RSNAST00,
Probably the other difference can be you don't update the protocol
Last thing RSNAST00 print only the message set to be printed by a program ( so VSZTP = 1 or 2)
Max
2014 Oct 01 11:44 PM
This was just the first test Max, I am still working through the requirement and making adjustments to the code.
I was initially desperate to find out how to re-print so that's why I posted this thread!
Thanks for the tip on VSTAT, good catch, I totally forgot about that.
I will include the output types (KSCHL) in the future, but waiting on the user to define all of the ones that she needs,