Skip to Content
-7
A S

Not showing entries when execute source code in Class

Hi im given an assignment to create, say purchase order entry using class (Encapsulate data in class method based on MVC design principles, in this case it is create operation). The table type is actually storing my zekko and zekpo.

Parameter declaration are in the screenshot.

This is the source code

if LV_ZEKKO03_COUNTS > 0 AND LV_ZEKPO03_COUNTS > 0.
    es_bapiret2-type = 'S'.
    es_bapiret2-id = 'Success'.
    es_bapiret2-number = '003'.
    es_bapiret2-message = 'Row(s) inserted'.
       select mandt ebeln bedat bsart lifnr waers knumv
  FROM ekko into CORRESPONDING FIELDS OF table it_zheader.
         INSERT zekko03 FROM table it_zitems.
         lv_zekpo03_counts = LINES( it_zitems ).


  SELECT mandt ebeln ebelp bukrs werks matnr menge meins netpr
  FROM ekpo INTO CORRESPONDING FIELDS OF TABLE it_zitems.

INSERT zekpo03 FROM TABLE it_zitems.
lv_zekpo03_counts = lines( it_zitems ).

else.
      es_bapiret2-type = 'E'.
    es_bapiret2-id = 'Error'.
    es_bapiret2-number = '004'.
    es_bapiret2-message = 'No row(s) added'.

endif.

If you have experience in this, do you mind sharing a better way of doing this?

capture.png (13.8 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Apr 21 at 08:31 AM

    >> Hi im given an assignment to create, say purchase order entry using class (Encapsulate data in class method based on MVC design principles, in this case it is create operation). The table type is actually storing my zekko and zekpo.

    I cannot understand how your 'assignment' is by any chance fullfilled by the coding you have presented.

    >> If you have experience in this, do you mind sharing a better way of doing this?

    This is a very open question. What is your actual problem or what do you want to improve or what are you unsure about?

    In regards to your coding, I could leave a comment for pretty much every line of code you have presented.

    • IT_xxx: Based on Hungarian notation, IT_xxx stands for Importing Table (imported into the function/form/method), and not internal (=local) table (processed within a function/form/method), which would be LT_xxx, and based on your mixed coding, I am not even sure if it should be one or the other or even both. Then there is also CT_xxx (Changing Table) and ET_xxx (Exporting Table). If you really want to keep using hungarian notation (which is getting outdated), at least be consistent.
    • IT_ZHEADER: you are dumping the entire content of EKKO into internal table IT_ZHEADER, but then you dont do anything with it, instead, you try to insert data from IT_ZITEMS into ZEKKO03 (maybe you wanted to load IT_ZHEADER into ZEKKO03?)
    • IT_ZITEMS: First you try to insert data from IT_ZITEMS (an importing or internal table?) into ZEKKO03, then you load everything from EKPO into IT_ZITEMS and try to insert that into ZEKPO03. I suspect that already should cause a syntax check error, as I suppose that the table type ZEKKO03 and ZEKPO03 are not the same and IT_ZITEMS can only be one of those
    • LV_ZEKKO03_COUNTS/LV_ZEKPO03_COUNTS: You only process your coding based on the IF-clause that those values have to be greater than Zero, yet you reassign those values later on again with the number of selected records. What is the relation between their beginning values and the later values?
    • ES_BAPIRET2: You set your success message prematurely before inserting the data, not even knowing whether any data has been inserted. I am assuming you can only do this, because of your knowledge between the dependence of the LVxxxCOUNT values and what your will be loading from the ZEKKOx tables.
      You set an error message, not based on an actual ERROR, but based on values being zero. This would normally just require an information, maybe a warning, but an ERROR?
      You misuse the fields of the return-structure, ID is a technical code representing a MESSAGE CLASS in the ABAP repository. The IDs "Success" and "Error" do not exist and therefore also not any message numbers related to that non-existing message class. If you want to create messages based on non-existing MESSAGE CLASSES, just leave ID and NUMBER empty, otherwise refer to your other question about BAPIRET2: https://answers.sap.com/questions/13028306/bapiret2-message-not-showing.html
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.