SAP ABAP Syntax for Describe part two

This is in continuation with sap abap syntax for describe part one.

Addition 2

... TYPE typ

Effect

Returns the data type of f in the field typ

Example

 DATA: FLD(8) TYPE N,
      F_TYPE.
DESCRIBE FIELD FLD TYPE F_TYPE.
 
Result:  F_TYPE  contains the value  'N' .
 Note
   Along with the elementary data types you can specify under  DATA  (C, N, etc.), several other data types are created either
with reference to Dictionary fields or during generation. These data types, which are also returned by  DESCRIBE , have the following
type IDs:h Internal table s 2-byte integer with leading sign b 1-byte integer without leading sign u Structure without internal table v Structure containing at least one internal table
For compatibility reasons, ... TYPE typ returns C rather than u or v with structures.

Addition 3

... TYPE typ COMPONENTS n
Effect

Similar to ... TYPE typ except that, with structures in typ , u or v are returned and in the number of structure components is set in n . If f is not a structure, n is set to 0.

Example

Recursive processing of the pages of an ABAP/4 data structure:
FORM TEST USING F.
  DATA: TYP(1) TYPE C, N TYPE I.
  FIELD-SYMBOLS: .
  DO.
    ASSIGN COMPONENT SY-INDEX OF STRUCTURE F TO .
    IF SY-SUBRC <> 0. EXIT. ENDIF.
    DESCRIBE FIELD  TYPE TYP COMPONENTS N.
    IF N > 0. " Equivalent is TYP = 'u' OR TYP = 'v'
      PERFORM TEST USING .
    ELSE.
      PERFORM DO_SOMETHING USING .
    ENDIF.
  ENDDO.
ENDFORM.
 
RELATED POST

SAP ABAP SYNTAX FOR DESCRIBE PART ONE

ERP basis and sap netweaver overview
MYSAP ERP advantages and main features

No comments :

Post a Comment