Skip to Content

Newbie trying to make use of code for query, table VBBE /SQ01/SQ02.

Hello!

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.

From discussion:

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.

START-OF-SELECTION.

       SELECT MATNR WERKS OMENG

                    FROM VBBE INTO TABLE IT_VBBE UP TO 500 rows.

BREAK-POINT.

LOOP AT IT_VBBE INTO WA_VBBE.

   COLLECT WA_VBBE INTO IT_VBBE_f.

ENDLOOP.



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 😊 😊

Untitled.png (19.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 29, 2015 at 05:41 PM

    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! 😊


    a1.png (15.7 kB)
    a2.png (11.5 kB)
    a3.png (12.8 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 19, 2015 at 12:19 PM

    Code looks good.

    Could you please paste snapshot of error from ST22 transaction?

    Add comment
    10|10000 characters needed characters exceeded

    • Bump 😔

      Does anyone know of a straight forward, noob-friendly guide, to retrieve result of internal table to a new, additional field in SQ02?

      As Tejas explained the internal table, how do i get the amount in the query-result for the material/plant?

      Material     Plant     Amount

      000001      P001     20

      000002      P001    10

      000002      P002    10


      Hope to hearing from you 😊

  • avatar image
    Former Member
    Oct 19, 2015 at 09:42 AM

    What runtime error are you getting ?

    Add comment
    10|10000 characters needed characters exceeded

    • I'm not able to see exactly what the error is. It's just a short dump without info.

      To be more specific, the error occurs in SQ01, when I'm trying to call the query. So it happens before the selection-screen.. if it helps.