Ansicht
Dokumentation

CFX_S_API_READ - Single API read object from cFolders

CFX_S_API_READ - Single API read object from cFolders

General Material Data   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

This function module allows to get all attributes of Materials, BOMs, Documents and Generic Objects using one single API call.

Fill in the "M_ID" of the corresponding tables ie., CT_MATERIAL, CT_BOM, CT_DOCUMENT,CT_GENERIC.

All the corresponding cFolders object will be read into the corresponding row of the above tables.

As the structure are reused for both CFX_S_API_READ and CFX_S_API_WRITE, some fields will not be used by both APIs , for an instance DELETE_ITEM in Generic object structure is not useful while reading of an object but relevant while changing an object.

The field BACKEND_NAME is used for identifying an object, uniquely, by the API. If the field "BACKEND_NAME" of the object to be read is not defined by the user the system will generate it and use it as a reference for the objects that are linked to the object to be read (e.g. documents or MPNs linked to a material).

Depending on the explosion level (import parameter I_EXPLOSION_LEVEL), also the linked objects as well as their attributes are provided.

For example:

,,Lets say we want to read a material so the M_ID of the material is set in CT_MATERIAL

,,if I_EXPLOSION_LEVEL is set to 2 then the MPNs attached to materials will also be read.

,,To read the complete details of the ECN and its attached object, i_explosion_level = 5 is required.

After the exectuion of API, the tables CT_GENERIC,CT_BOM,CT_DOCUMENT, CT_GENERIC will contain the attribute details and also the information regarding the objects that are associated to them.

For example:

,,If there are MPNs linked to a material, then the VERSION_ATTR table will contain

,,the attribute id as MPNS [ CL_CFX_S_API_HLP=>SC_LINK_MPN_CL_TYP ]

,,the attibute value will be a BACKEND_NAME reference.

To get the GUID for a BACKEND_NAME please refere to the table CT_IDS it will contain, finally, the complete list of the objects that were exploded along with type of object and their GUIDs.

Example

This example will give you an idea how to use this API.

Create a 'Z_S_API_READ' program to call the CFX_S_API_READ API

*&---------------------------------------------------------------------*

*& Report Z_S_API_READ

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT z_s_api_read.

*Types

TYPE-POOLS: cfxf1,

cfxa0,

abap.

*General Declaration

DATA : lt_fault TYPE cfx_s_api_tt_fault,

ls_fault TYPE cfx_s_api_ts_fault,

l_error TYPE cfx_api_t_bool,

ls_id TYPE cfx_s_api_ts_ids,

lt_ids TYPE cfx_s_api_tt_ids,

lt_document TYPE cfx_s_api_tt_document.

*Material Declaration

DATA : lt_material TYPE cfx_s_api_tt_mat_read,

ls_material TYPE cfx_s_api_ts_mat_read,

ls_attr_value TYPE cfx_api_ts_attribute_value.

*BOM declaration

DATA : ls_bom TYPE cfx_s_api_ts_bom_read,

lt_bom TYPE cfx_s_api_tt_bom_read,

ls_item TYPE cfx_s_api_ts_item,

ls_item_attr TYPE cfx_api_ts_item_attrib_value.

*Generic Object declaration (MPN)

DATA : ls_generic TYPE cfx_s_api_ts_generic,

lt_generic TYPE cfx_s_api_tt_generic,

ls_field_value TYPE cfx_api_ts_go_field_value.

DATA: ls_alias_value TYPE cfx_api_ts_alias_name_value.

DATA: lt_folder_id LIKE TABLE OF cfx_fol-folder_id.

DATA: l_folder_id LIKE cfx_fol-folder_id.

DATA: l_topic_id TYPE string.

CLEAR : ls_generic.

*Generic Object (ECN)

ls_generic-m_id = ''."GUID of the ECN

ls_generic-backend_name = 'ecn1'. "API will refer the ECN using this name

APPEND ls_generic TO lt_generic.

*call to single API

CALL FUNCTION 'CFX_S_API_READ'

EXPORTING

i_explosion_level = 2

IMPORTING

et_fault = lt_fault

e_error = l_error

CHANGING

ct_bom = lt_bom

ct_material = lt_material

ct_generic = lt_generic

ct_document = lt_document

ct_ids = lt_ids.

"LT_IDS will contain all the objects read, their type and GUIDs.

DATA l_type_id TYPE string.

IF l_error = cfxa0_sc_true.

WRITE : 'An error occurred.'.

SKIP.

LOOP AT lt_fault INTO ls_fault.

WRITE:/'Error Occured during processing object wth Backend Name::',ls_fault-backend_name.

l_type_id = ls_fault-type_id.

WRITE:/'With Type::', l_type_id.

WRITE:/'Cause of error ::',ls_fault-faultstring.

ENDLOOP.

ENDIF.

Notes

Further information





Parameters

CT_BOM
CT_DOCUMENT
CT_GENERIC
CT_IDS
CT_MATERIAL
ET_FAULT
E_ERROR
I_EXPLOSION_LEVEL

Exceptions

Function Group

CFX_S_API_DOC

rdisp/max_wprun_time - Maximum work process run time   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 6042 Date: 20240523 Time: 110550     sap01-206 ( 75 ms )