SAP ABAP Syntax for Describe part three

This post is in continuation with SAP ABAP syntax for describe part two .

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.

Addition 4

... OUTPUT-LENGTH len

Effect

Enters the output length of the field f in the variable len .

Example

 DATA: FLD(4) TYPE P,
      O_LEN TYPE P.
DESCRIBE FIELD FLD OUTPUT-LENGTH O_LEN.
 
Result: O_LEN contains the value 8.

Addition 5

... DECIMALS n

Effect

Enters the number of decimal places for the field f (defined in addition ... DECIMALS of the DATA statement or in the ABAP/4 Dictionary ) in the variable n .

Example

 DATA: FLD(8) TYPE P DECIMALS 2,
      DEC TYPE P.
DESCRIBE FIELD FLD DECIMALS DEC.

Resultat: DEC contains the value 2.

Addition 6

... EDIT MASK mask

Effect

If the field f has a conversion routine in the ABAP/4 Dictionary , this is placed in the field mask in the form " ==conv ". " conv " stands for the name of the conversion routine, e.g. " ==ALPHA " in the conversion routine " ALPHA ". In this form, mask can then be used in the addition USING EDIT MASK mask of the WRITE statement.

Example

Check whether there is a conversion routine for the field "customer number" in the table SBOOK :
 TABLES SBOOK.
DATA: CONV_EXIT(10).
DESCRIBE FIELD SBOOK-CUSTOMID EDIT MASK CONV_EXIT.
IF CONV_EXIT <> SPACE. ... ENDIF.

Result: CONV_EXIT contains the value " ==ALPHA ".

RELATED POST

No comments :

Post a Comment