WRITTEN BY: supportmymoto.com STAFF
The instance beneath are primarily based on my want to carry and switch two fields from LIKP. It’s straightforward to broaden to carry different desk buildings or single fields.
The datastore might be used to interchange the utilization of MEMORY ID, which aren’t very readable / maintanable.
A (very) brief introduction for individuals who should not conversant in the singleton design sample. The singleton design sample ensures that just one occasion of the category is created. The category incorporates its personal constructor, and on this technique logic is positioned that ensures the creation of just one occasion.
And now for the enjoyable half. I’ve documented the code(!), so it must be readable with simply screenshots.
The category for the information retailer:
And the O_DATA_STORE attribute:
The constructor for the category is the GET_OBJECT technique.
And two easy PUT and GET strategies for the LIKP construction:
Use of sophistication
The next is the take a look at program that reveals the datastore in use.
First the principle program:
The following stage within the name stack:
And the final stage of the decision stack:
At this level the LIKP-VBELN incorporates the quantity 2. This present that our information retailer object are stored in reminiscence the entire manner by way of the decision stack.
Please be aware that when you depart the decision stack (i.e. begin one other report), then you’ll free the reference to the thing.
With this datastore class now you can keep away from utilizing MEMORY ID to retailer and transfer variables trough the decision stack.
After the preliminary construct of the category I’ve enhanced it additional, and adjusted the GET-methods with a return parameter to judge if the sector has been saved.
I additionally added a RESET-method. This technique marks the sector as unstored.
This has the benefit of having the ability to test if the sector have been initiated. And in addition to reset the sector after it have been retrieved/used.
METHOD put_berot. v_berot = i_berot. v_berot_initiated = abap_true. ENDMETHOD.
METHOD reset_berot. v_berot="". v_berot_initiated = abap_false. ENDMETHOD.
METHOD get_berot. e_berot = v_berot. r_berot_initiated = v_berot_initiated. ENDMETHOD.