Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Not showing entries when execute source code in Class

former_member670450
Participant
0 Kudos

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?

3 REPLIES 3

michael_piesche
Active Contributor
0 Kudos

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

matt
Active Contributor
0 Kudos

I suggest that before you post more questions with the same errors, you address the answers given here:

https://answers.sap.com/questions/13028306/bapiret2-message-not-showing.html

michael_piesche
Active Contributor
0 Kudos

arnold92, please follow up on your open question.

  • comment answers or your question if there are still open issues.
  • otherwise mark an answer as accepted if it helped you solve your problem
  • or post an answer of yourself and accept it if you found another useful solution yourself
  • or redirect your question to another question that is related and was useful to solve your problem
  • in the end, close your question