Reading attribute of a BOR (Business Object) in ABAP
来源:互联网 发布:自然灾害预警软件 编辑:程序博客网 时间:2024/05/18 18:17
Many times I've looked at transaction SWO1 for a business object and seen how it displays all sorts of useful functions (e.g Line Item Texts etc. etc.). Many of these attributes can only be got at in normal programming via convoluted abap tinkering. -- How many times for example do you want to get texts to include on a smartform etc.
However it's really easy to get the attribute from the BOR itself using very simple coding.
Most people shy away from this since a BOR is usually used in SAP workflow and most abap developers haven't had a lot of exposure to OO programming or SAP workflow.
Anyway here's sample code to return an Attribute of a BOR.
program zzreadbor.* Get an attribute of a business object.parameters: p_busobj(10) type c default 'BUSISM007', "IS Media customer p_key(70) type c, p_attr(32) type c default 'Xmediacustomer'.data: i_objtype TYPE swo_objtyp, i_objkey TYPE swo_typeid, i_element TYPE swo_verb. DATA object TYPE swo_objhnd. DATA verb TYPE swo_verb. DATA return TYPE swotreturn. DATA lt_container TYPE STANDARD TABLE OF swcont. data line type swcont.i_objtype = p_busobj.i_element = p_attr.i_objkey = p_key.* instantiate the business object. I.e give it a key and create it. CALL FUNCTION 'SWO_CREATE' EXPORTING objtype = i_objtype objkey = i_objkey IMPORTING object = object.* return attribute. CALL FUNCTION 'SWO_INVOKE' EXPORTING access = 'G' object = object verb = i_element IMPORTING return = return verb = verb TABLES container = lt_container.* the attribute value is returned in field line-value. IF return-code = 0. loop at lt_container into line. write: / line-value. endloop.endif.
* The above example will return an 'X' if the customer is an IS Media customer or blank otherwise.
Other good business objects to use are sales docs (header / line items), invoices, Info types etc etc.
You can also call methods this way as well -- change the access to 'C' in the SWO_INVOKE and pass the parameters to the method. Method name is in VERB. A bit more complex as in the case of Supertypes you need to find the program -- will post an example later --however to start with even the attributes are useful since on "Instantiation" of the BOR you have access to ALL the attribites of that BOR.
- Reading attribute of a BOR (Business Object) in ABAP
- BOR (Business Object Repository )
- silverlight中的clone: Deep Clone of a business object: the quick and dirty way
- Defining a Business Add-In
- Business Object Validation Using Attributes in C#
- AttributeError: 'Graph' object has no attribute 'cypher' in migration of data from Postgress to Neo4
- READING NOTE: A Pursuit of Temporal Accuracy in General Activity Detection
- the Mechanical Action of a Boolean Object in labview
- Adding a custom method in an ADF BC Service Interface – update of a single attribute in a selected r
- Business Object
- Interpretation of a business-cultural event
- The Key Responsibilities of a Business Analyst
- Reading src of DriverWorks in DriverStudio 3.2
- Reading Response of Component Configurator in POSA2
- 读Excel:Reading excel in a ListBox
- A Reading List in Computer Networking
- custom format Property of business object for the data binding
- Xcelsius and Session Management in Business Object XI 3.0
- linux 初始化的7个段
- javac札记—— -encoding
- ORACLE的网络配置,与权限初步
- MCR & MRC
- ACM-2011 PKU 比赛
- Reading attribute of a BOR (Business Object) in ABAP
- typedef函数指针的用法(附例子)
- 三级菜单联动
- 开心一刻
- Dalvik 简介
- url
- kinect开发的openni使用
- 用C++实现单词分割
- 虚继承和虚函数的实质