Newbie trying to make use of code for query, table VBBE /SQ01/SQ02.
I'm trying to make a couple queries which needs some coding. I'm not an ABAPer at all, but have practical knowledge with simple queries/ adding calculation-fields etc.
Theres mainly two queries I would love to have, and I've seen a couple threads and code-snips aiming to achieve just what I'm trying to get.
Ie., I'm trying to get table VBBE field OMENG summarized at plant level (directly in the result, so I can use that sum to calculate in additional fields).
However, I'm obivously terrible at this, as I'm not getting it to work.
TYPES: BEGIN OF ST_VBBE ,
MATNR TYPE VBBE-MATNR,
WERKS TYPE VBBE-WERKS,
OMENG TYPE VBBE-OMENG,
END OF ST_VBBE.
data : IT_VBBE TYPE TABLE OF ST_VBBE,
WA_VBBE TYPE ST_VBBE,
it_vbbe_f TYPE TABLE OF st_vbbe,
WA_VBBE_F TYPE ST_VBBE.
SELECT MATNR WERKS OMENG
FROM VBBE INTO TABLE IT_VBBE UP TO 500 rows.
LOOP AT IT_VBBE INTO WA_VBBE.
COLLECT WA_VBBE INTO IT_VBBE_f.
Exactly where do I put this to use?
What I've done is:
- Created table joins in SQVI
- Converted the quickview in SQ01
- Then adding this whole code in SQ02, Extras -> Code -> Section: Data
I bet this is horribly wrong and theres pieces missing, but the code gives no syntax errors while in SQ02.
Also 'Infoset xxxxx has no inconsistencies' when I do a check of it.
But when I save this, and trying to execute in SQ01, I get an ABAP runtime error :-/
As the discussion-title indicates of course, do I need to COLLECT this data somehow?
How do I do that?
Any advice or a small guide to using this code-snippet would mean a lot to me
Vegard R replied
Thanks to everyone who tried to help me out.
With some help, I managed to find the solution to my requirement, which was a lot easier than I originally thought.
I created an Extra -> 'Additional field' in SQ02. Called it TOT_OMENG with these settings:
(I later found out I wanted the values from field VMENG instead of OMENG)
Then in 'Coding for addition' (button to the left of "Sequence"), I used the following code:
So, this code just sums up the VMENG-column of table VBBE, based on EKPO-MATNR og -WERKS, and the material av.date (VMENG) less than or equal to the system date.
Then I put this additional field into the same field-group as the rest.
Then in SQ01, I could go to the basic list output and select this new field. Voila!