Monday, August 26, 2019

QtmhWrStout

The solution for the challenge listed bellow was not to use QtmhWrStout but to use the YAJL  yajl_writeStdout routine as in Scott Klement's article and not the open source provided for STOCKQTY REST.

Also EXTPGM should have been EXTPROC
----------------------------------------------------------------------------------------------------------------

I can't seem to get this to work using fully/totally free RPG so resorted to RPG free IV:

Here is the code

Message ID . . . . . . :   MCH3401       Severity . . . . . . . :   40       
Message type . . . . . :   Diagnostic                                        
Date sent  . . . . . . :   22/08/19      Time sent  . . . . . . :   12:52:38 
                                                                             
Message . . . . :   Cannot resolve to object QtmhWrStou. Type and Subtype    
  X'0201' Authority X'0000'.                                                 
Cause . . . . . :   Either a system pointer or a data pointer can not be     
  resolved.                                                                  
    For a system pointer, it can not be resolved to object QtmhWrStou, type  
  and subtype X'0201', authorization X'0000', because either the named object
  was not in any context referred to or the correct object was located but the
  user profile did not have the required authority.                          
    The object types for some common type or subtype codes follow:           
    -- 0190-Access group, 0201-Program, 0401-Library,                        
    -- 0701-Journal receiver, 0801-User profile, 0901-Journal,               
    -- 0B90-Data space, 0C01-Directory, 0C90-Data space index,               

005200    DCL-PR   QtmhWrStout     EXTPGM('QtmhWrStout');              
======>                                   aaaaaaaaaaaaa                
*RNF0646 10 a      005200  Library or object name exceeds 10 characters.
005300             DTAVAR          VARCHAR(200000) CONST;              
005400             DTAVARLEN       INT(10) CONST;                      
005500             ERRORCODE       VARCHAR(8000);                      
005600    END-PR;    

                            

1 comment:

  1. Here is a code snippet of what I use – Declaration : Note the Keyword ExpProc vs ExtPgm that you’ve used.
    Dcl-pr WriteToApache extproc('QtmhWrStout');
    DtaVar Pointer value;
    DtaVarLen Int(10:0) const;
    Code Like(APIError);
    End-pr;

    Dcl-ds APIError;
    EBytesP Int(10:0);
    EBytesA Int(10:0);
    EMsgID Char(7);
    EReserved Char(1);
    EData Char(1);
    End-ds;



    Inplementation:
    Headers = 'Status: ' + %Char(sts) + CRLF +

    'Content-type: application/json charset=utf-8' + CRLF +

    'Content-Disposition: attachment; filename=' + %Trim(w_File) + CRLF + CRLF;

    WriteToApache( %addr(Headers) + 2 : %len(Headers) : APIError );

    WriteToApache( jSonBuf : jsonSize : APIError );



    I needed to supply additional headers, therefore 2 times flush to Apache. The second is the actual json payload.

    ReplyDelete