How To add Attribute Dynamical in Existing Context Node

*-------------------------------------------------------
*  add attribute in existing context node
*-------------------------------------------------------
  data LR_PAR_NODE type ref to IF_WD_CONTEXT_NODE_INFO.
  data LR_NODE     type ref to IF_WD_CONTEXT_NODE_INFO.
  data LT_ATT      type STRING_TABLE.
  data LR_ATTRIBUTE type WDR_CONTEXT_ATTRIBUTE_INFO.
*****to get context node information
  LR_PAR_NODE = WD_CONTEXT->GET_NODE_INFO( ).
* Name of node where you want to add attribute
  LR_NODE = LR_PAR_NODE->GET_CHILD_NODE( `TEST` ).
*  get all existing attribute name
  LT_ATT = LR_NODE->GET_ATTRIBUTE_NAMES( ).
  LR_ATTRIBUTE-NAME = `DUMMY`.
  LR_ATTRIBUTE-TYPE_NAME ='CHAR40'.
*  check attribute is present or not
*  if not present then create attribute in node
  read table LT_ATT transporting no fields
              with key TABLE_LINE = `DUMMY`.
  if SY-SUBRC ne 0.
    call method LR_NODE->ADD_ATTRIBUTE
      exporting
        ATTRIBUTE_INFO = LR_ATTRIBUTE.
    clear LR_ATTRIBUTE.
  endif.

Comments

Popular posts from this blog

Alternative to READ_TEXT Function Module (to fetch multiple long text at one go )