1 1 1 1 1 Rating 0% (0 Votes)

If you would ask me if I would write something about SAP Script then I would definitely answer "Hell no!". I hate SAP Script to be honest, it has for me only one advantage - speed of printout if you compare it to Adobe Forms, but the rest for me..... is against.

 

Today I faces a really strange behaviour of one of the invoice printouts, one of the fields which was showing the tax percentage, was showing wrong value if the print program was called for the second time.

 

The first output was OK, 8,00 % as value.

 

 

 

But when I directly show again the preview of the same invoice then, the value was changed to 0,80 %.

 

Read more ...

5 1 1 1 1 1 Rating 100% (11 Votes)
I know that many times showing any progress information isn't something that developer likes to have in his program, especially when it's so fast that progress indicator only slows it down horribly, but often we're putting it into code, when program runtime is quite long ( more than 1 minute) and we want to show the users that program is running and we're currently at step m of n.  Since I remember I was always using SAPGUI_PROGRESS_INDICATOR FM to display such messages on the screen. When used inside loops I often was manually dividing current tabix by selected variable (for example 1000) and if there was no rest from such division then I was running this FM, just to avoid calling this FM to often. The problem of this FM is that when used in background it hasn't show any info in job log. So if you wanted to have also entries in job log, then additional lines with checks if this is foreground or background mode were needed, and if we were in bg mode then messages instead of progress indicator had to be used. 
Read more ...

5 1 1 1 1 1 Rating 100% (3 Votes)
Attachments:
Access this URL (http://abapblog.com/files/nugg/ZAB_MASS_REPLACE.nugg)ZAB_MASS_REPLACE.nugg
When using editable ALV mass replace function is needed very often, but when it comes to creating it you have to choose which from the not so perfect possibilities you should use. You can create a screen or selection-screen with all possible fields which can be used in the function (not good when you have a lot of editable fields), you can create dynamic program and submit it (not good as then you switch to the screen of generated) or you can create a FM to call selection-screen in separate task (disadvantage is that user can click on original window and hide your popup). I've used all of these possibilities but when you'd like to reuse them then third one (FM to call dynamic selection-screen in separate task) seems the best. 
 
First of all the question is why do we need separate task to call it? Well, when you call dynamic selection-screen (with parameters like (variable) ) for the first time the output is ok, but the second time you do it in the same runtime of transaction or program then the length, type and F4 help are just like for the field generated for the firs time. This is because the generated selection screen is kept in memory an called each time with same parameters, nevertheless the change of "variable". The way to omit it is to call this selection-screen in new task. This will force SAP to regenerate selection-screen each time.
Read more ...

5 1 1 1 1 1 Rating 100% (1 Vote)
Tags: MD07 , MS07 , MDC7 , MSC7
Attachments:
Access this URL (http://abapblog.com/files/nugg/ZAB_EXTMD07.nugg)ZAB_EXTMD07.nugg
You may noticed that standard transaction MD07 and MS07 offers basic filters on selection-screen which allows user to select materials they are responsible for, the problem comes when in your company users wants to be more precise in filtering or when the responsibility is set not only on a base of MRP controller. Fortunately SAP gives us the possibility to call MD07 and MS07 with our own list of materials using dummy transaction codes MDC7 and MSC7. All you need to do is to prepare a table of type MDMWX, export it to memory 'START_MD07and call dummy t-code. Bellow you can find an example of the report to call MD07/MS07 with own material list where on selection screen you can find for example purchasing group which is not available in standard. You can also find a link to nugg file.
Read more ...

5 1 1 1 1 1 Rating 100% (2 Votes)
If you have to adjust conditions for your purchase order line and if during the use of method if_purchase_order_item_mm~set_conditions in BADI ME_PROCESS_PO_CUST you receive an error MEPO151 "Data from Business Add-In ME_PROCESS_PO_CUST not adopted" then after you check SAP notes for that error and none of them help then you may try with solution which you can find bellow. The endless loop appears because set_conditions method force re-check of the item. To avoid running set_conditions more than once in one check of the item I used abap memory to store data about each line that was check. I've created simple structure with ebelp and "set" fields on a base which I know if I had to run setting of conditions or not.  Maybe it's not the nicest solution but it works quite well :)
The form which you can find bellow you have to run at the end of processing of method process_item of ME_PROCESS_PO_CUST to be sure that other form will not force SAP to re-check the item again.
Read more ...

1 1 1 1 1 Rating 0% (0 Votes)
When you will want to create a customization table for your program but you want to do it that way that you want to have many key fields and some of them can be empty which would mean that this is valid for all entries then you have to do some little coding to handle it as you just cannot check only if key fields are same as in your checked structure. There is a way to do it and the method described can be used in all programing languages. I will show you two ways - static and dynamic.
In static one I will hard code key field names in the code which makes that you have to rewrite the code each time you change the structure of your configuration table. 
Dynamic way when done once then doesn't have to be redesign as I will use cl_abap_elemdescr and cl_abap_structdescr to get key fields. 
 
Ok, firstly we need to create our configuration table in dictionary using SE11. As sample I will create table only with two key fields on a base whom I will check the configuration.
 
Read more ...

1 1 1 1 1 Rating 0% (0 Votes)
When you need to call a FM with option starting new task there is always a risk that user already has maximum number of sessions opened, so there is a risk that our call will be unsuccessful. There is a way to avoid such risk -> easily call FM  RM_FREE_SESSION_CHECK or TH_USER_INFO directly to check if we can afford to open new session. If yes then we can call our FM in new task, if not then we can raise an error message and stop processing of the function we're currently doing. This is very helpful when you need to call a FM in new task inside user-exit.
 
Here is example of the code:
Read more ...