Domain: String functions/test functions
The SDF-STRUCTURE-VALUE( ) function supplies part or all of the contents of an SDF structure.
Format
SDF-STRUCTURE-VALUE( ) |
STRING = string_expression ,OPERAND-NAME = *ROOT / string_expression / arithm_expression ,ATTACHED-STRUCTURE = *YES / *NO |
Result type
STRING (<string>)
Input parameters
STRING = string_expression
Name of the string which is to be analyzed. This is checked internally by an IS-SDF-STRUCTURE( ). Refer therefore to the description of this latter function.
OPERAND-NAME = *ROOT / string_expression / arithm_expression
Name of the operand or position where the value is to be found.
Only directly addressed operands are checked, or the operands on the directly addressed level. Other operands or operands on other levels must be addressed separately.
ATTACHED-STRUCTURE= *YES / *NO
Specifies whether the structure affected should be specified or not.
Result
The required expression in the form of a string.
Error messages
SDP0460 THE GIVEN STRING IS NOT A STRUCTURE SDP0461 THE NUMERIC VALUE FOR THE OPERAND MUST BE GREATER THAN ZERO SDP0462 ‘(&00)‘ IS NOT A STRUCTURED-NAME SDP0463 THE GIVEN OPERAND ‘(&00)‘ IS UNKNOWN SDP0464 TOO MANY AMBIGUITIES FOR THE GIVEN OPERAND SDP0465 OPERAND OF TYPE BOOLEAN NOT ALLOWED
Example 1
/START-SDF-A //OPEN syssdf.myuser,type=user,mode=create //ADD-CMD my-cmd-1,IMPL=*PROC('myproc') //ADD-OPERAND op //ADD-VALUE *NAME //ADD-VALUE *KEYWORD(STAR=*MANDATORY),STRUCTURE=*YES,VALUE='PARAMETERS' //ADD-OPERAND op1,RESULT-OPERAND-LEVEL=2 //ADD-VALUE *NAME //ADD-OPERAND op2,RESULT-OPERAND-LEVEL=2 //ADD-VALUE *FILENAME //CLOSE-STRUCTURE //END First, an SDF syntax file with the name SYSSDF.MYUSER is created in which the command MY-CMD-1 is defined. This command is implemented by the MYPROC procedure (see the SDF-A statement //ADD-CMD).
Contents of the MYPROC procedure:
/SET-PROCEDURE-OPTIONS "Procedure: myproc" /BEGIN-PARAMETER-DECLARATION / DECLARE-PARAMETER op /END-PARAMETER-DECLARATION /value=SDF-STRUCTURE-VALUE(op,*ROOT,*NO) /WRITE-TEXT 'root value : &value' /value=SDF-STRUCTURE-VALUE(op,'OP1') /WRITE-TEXT 'operand op1 value : &value' /value=SDF-STRUCTURE-VALUE(op,'OP2') /WRITE-TEXT 'operand op1 value : &value' /EXIT-PROCEDURE
The syntax file must be activated in order to call the MY-CMD-1 command:
/MODIFY-SDF-OPTIONS *ADD(ADD-NANE=syssdf.myuser)
Call for the MY-CMD-1 command:
/MY-CMD-1 OP=*PARAMETERS(OP1=VALUE1,OP2=VALUE2)
Output
root value: *PARAMETERS operand op1 value: VALUE1 operand op2 value: VALUE2
The command MY-CMD-1 calls the procedure MYPROC and returns the contents of the specified OP structure.
Example 2
/A=‘*PARAMETERS(OP1=val1(OP11=val11,OP12=val12),OP2=val2(val21,val22))‘ /B=SDF-STRUCTURE-VALUE(A,‘OP1‘,*YES) /SHOW-VAR B B=val1(OP11=val11,OP12=val12) /C=SDF-STRUCTURE-VALUE(B,‘OP11‘) /SHOW-VAR C C=val11 /D=SDF-STRUCTURE-VALUE(B,2) /SHOW-VAR D D=val12