U@GENERICAPIVL

U@GENERICAPIVL is an API that allows you to quickly test for the existence of a hidden API. You need to supply the index number of the hidden API to test for and then the U@GENERICAPIVL will run U@GENERICAPI with "V" (for validate) as the E@GNAPFUNC value. Either FOUND or NOTFOUND will be returned in the E@GNAPRESULT field. (The hidden API is not actually run by this call.)

Module SYSCMDS

Input

Field Definition
E@GNAPAPIINDEX

Number indicating which of the hidden APIs is called by the Generic API. Valid values are from 1 to 99. A special test API has already been assigned a value of 90, so any new hidden APIs do not have this value. To call the hidden API, the RPG program must have the index value for the hidden API:

2 = calls the hidden API that gets the size of the file.

3 = calls the hidden API that copies a single file to the destination directory.

4 = calls the hidden API that creates directory along with any required parent directories.

7 = calls the hidden API that creates empty files.

Output

Field Definition
E@GNAPRESULT Result of the call through U@GENERICAPI , either FOUND or NOTFOUND.

Programming Example

The following shows the use of U@GENERICAPIVL to check for the existence of the test hidden API.

    EVAL      E@GNAPAPIINDEX = 90
	CALLP     U@GENERICAPIVL                               Generic Api Validati
    IF        E@GNAPRESULT = *ZEROS
    
    CALLP     U@STR@INIT(%ADDR(E@STR@DS): *NULL: 1: 54:
              1)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS):
              'Generic API Test API was Not Found': 1:
              34)
    CALLP     U@STR@PRT(%ADDR(E@STR@DS): 1)
    
    ELSE
    IF        E@GNAPRESULT = 999
    
    CALLP     U@STR@INIT(%ADDR(E@STR@DS): *NULL: 1: 60:
              1)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS):
              'Generic API Test API Failed - Error: ':
              1: 37)
    EVAL      E@STR@PRTFLD   = %CHAR(E@GNAPERRNBR)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS):
              E@STR@PRTFLD: 1: %LEN(E@STR@PRTFLD))
    CALLP     U@STR@PRT(%ADDR(E@STR@DS): 1)
    
    
    CALLP     U@STR@INIT(%ADDR(E@STR@DS): *NULL: 1:
              131: 1)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS):
              'Error Msg: ': 1: 11)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS):
              E@GNAPERRMSG: 1: %SIZE(E@GNAPERRMSG))
    CALLP     U@STR@PRT(%ADDR(E@STR@DS): 1)
    
    ELSE
    IF        E@GNAPRESULT = 1
    EVAL      E@GNAPINPRMS   = 'This is in the first 5-
              0 bytes of the Input Buffer'
    EVAL      E@GNAPFUNC     = 'R'
    CALLP     U@GENERICAPI                                 Generic Api
    IF        E@GNAPRESULT = 999

    CALLP     U@STR@INIT(%ADDR(E@STR@DS): *NULL: 1: 66:
              1)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS): 'Run of Ge-
              neric API Test API Failed - Err': 1: 40)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS): 'or:': 1:
              3)
    EVAL      E@STR@PRTFLD   = %CHAR(E@GNAPERRNBR)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS):
              E@STR@PRTFLD: 1: %LEN(E@STR@PRTFLD))
    CALLP     U@STR@PRT(%ADDR(E@STR@DS): 1)
    
    
    CALLP     U@STR@INIT(%ADDR(E@STR@DS): *NULL: 1:
              131: 1)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS):
              'Error Msg: ': 1: 11)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS):
              E@GNAPERRMSG: 1: %SIZE(E@GNAPERRMSG))
    CALLP     U@STR@PRT(%ADDR(E@STR@DS): 1)
    
    ELSE
    
    CALLP     U@STR@INIT(%ADDR(E@STR@DS): *NULL: 1:
              3020: 1)
    CALLP     U@STR@ITEMSZ(%ADDR(E@STR@DS):
              E@GNAPOUTPRMS: 1: %SIZE(E@GNAPOUTPRMS))
    CALLP     U@STR@PRT(%ADDR(E@STR@DS): 1)

    ENDIF
    ENDIF