Copyright 2024 - BV TallVision IT

Coding example which can fetch an object from a live / used container. This example demonstrates how a container works. 

The container can be addressed by GETting and SETting elements or objects from it / to it. The macro's SWC_GET_ELEMENT and SWC_SET_ELEMENT are available to you too !

BEGIN_METHOD ZUFETCHIDOCOBJECT CHANGING CONTAINER. 
*--------------------------------------------------------
data: l_idocnumber like edidc-docnum,
      l_result_object like OBJ_RECORD.

* The Idocnumber is a required input field, without it 
* the method will not do anything
SWC_GET_ELEMENT container 'IdocNumber' l_idocnumber.
check sy-subrc = 0. "Idoc number was available

* Attempting to create a IDOC object with an Idoc number 
* that does not exist is something that
* should be avoided
select single docnum from edidc into l_idocnumber
  where docnum = l_idocnumber.
check sy-subrc = 0. "Idoc number is valid 

* The following macro´s will take care of creating the Idoc 
* (or rather business object IDOC)  business object, and
* place it on the container (exporting it out)
SWC_CREATE_OBJECT l_result_object 'IDOC' l_idocnumber.
SWC_SET_ELEMENT container 'IDOC' l_result_object.

END_METHOD.