Link to home
Start Free TrialLog in
Avatar of ICINTRACOM
ICINTRACOM

asked on

ABAP A304 Not getting all records

I'm trying to pull the material pricing rules from SAP using A304 to get the condition number and then using the condition number to query KONP.  The issue is that it's not pulling all the records.  I can go to transaction v/ld and clearly see the pricing conditions for the material in question.  However when I try to view the material in SE16 it comes up with no records.  Is there a better way to get pricing rules?  I don't want what was on an order I just want a list of materials and the pricing rules (ie material 123456 buy 1 for $10.00, buy 5 for $8.00).  Here is my code (partial because the program is more invovled than just this)

* Get the Materials list
    SELECT  MATNR
            KNUMH
            DATBI
            DATAB
    INTO TABLE i_mat
    FROM A304
    WHERE VKORG EQ p_cocode AND VTWEG EQ p_chan
    AND KSCHL IN s_contyp.

IF NOT i_mat[] IS INITIAL.
* Get Sales Price
    SELECT KNUMH
           KSCHL
           KBETR
           KONWA
           KSTBM
    INTO TABLE i_saleprice
    FROM KONP
    FOR ALL ENTRIES IN i_mat
    WHERE KNUMH EQ i_mat-connum.
END IF.

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of ICINTRACOM
ICINTRACOM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Twisteddk
Twisteddk

Dude... Dont move data from your tables. That's just going to create inconsistencies.
Rather reference the data with a new view over the tables that you have identified as containing the information you're looking for. This way you have ready access to the data through your view, and the data doesn't have to move.
Avatar of ICINTRACOM

ASKER

Twisteddk,
I'm "moving" data to an one internal (im memory table) so I can export the data.  "MOVE" is just a keyword that ABAP uses to copy data from one table to the another.
Well, you said differently in your statement. You select the data (into a table) in your querry and then you say you move it. But as long as you mean moving the RESULTING data, not the original, then feel free to do with is as you wish, though I do not understand WHY you'd want to move your resulting data anywhere, but that's a technicality.  As long as you're aware that you're "only" working with a copy, then it's ok from an Oracle and an SAP point of view, though you WILL be stressing the heap and roll memory on your SAP system by doing this (selecting into an internal table, and even the moving an internal table part)
In essence, you run the risk of creating a program that'll run fine in your development system, but will dump (ora-1555 or a simple SAP timeout assuming your program runs in dialog mode) on your productive system.

I do not know how many material numbers you have, but I'd wager that if you have more than 50.000 then your querry is rather slow.
By "simply" creating a new view (I'm assuming A304 IS a view since you were unable to view the data within it ? I dont have access to any of our SAP systems from this PC, so I can't check for you) over the desired data you can select the data in mere miliseconds (assuming the required indices exists). Also, you wont stress the memory and rollback segments in the SAP system.
Anytime you select into an internal table, you run the risk of using up the EM memory if you select too large a segment of data, or not enough memory is available to process the request. By creating a view you may have a larger dataset, but you dont need to create it every time you want to access it.
From a computer science point of view you're bending the relational database rules by creating a redundant dataset. This would be ok, if it is done for the purpose of expediency. Unfortunately, as you create the dataset every time you run your querry, you're just wasting CPU cycles (not to mention disk resources). It'll run, yes, but only if you have enough resources available to run the program.
The fact that your resulting dataset WONT change from one run to the next should indicate to you that re-creating the resultset with every call of your transaction or program is inefficient. This is why you normally have a hefty report generation in a BW system.

But, if you only need to run the querry once in a while, or you have very little data to select from, this may not be an issue for you, and you can disregard my advice about a view.

I just thought I'd let you know. I've seen many ABAP programmers try to work with internal tables, and not know the extend of their querry. I've even seen one who tried to "copy" almost the entire database into a single internal table. Be wary of the IT. Especially when working with large or unknown datasets.
Closed, 250 points refunded.
Vee_Mod
Community Support Moderator