submit job with parameters

95 pts.
Tags:
Submit Job
I have 10 parameters and the last 7 are 77 long. Per job log, the parameters are not 77 when submit. They were truncated the spaces. How can I fixed it?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

The best way is to create a command over your program to call/submit it so you can define the parameters to be passed.  A “kludgy” trick that might work is to pass an additional (78th in this case) character that is non-blank to force the sbmjob to not truncate off the spaces as they are now not trailing.   This works because the program only reads the 77 characters it is expecting to get. In the example below the ‘*’ is the extra non-blank parameter.

call program 'long parameter                                    *' 

Discuss This Question: 21  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Subhendu Sen
    What hardware/ software are you using now? What OS is there? Is this your office/ a personal? What parameter did you ask for? Please provide more details.
    140,150 pointsBadges:
    report
  • MariaMYD

    Power 9. OS400 V7R3.  This is for work.  I have a small program with a prompt screen.  User fills in the requirement on screen, call the CL to passed 10 parameters with length of 3, 1, 8. 77, 77, 77, 77, 77, 77, 77.  Somehow when the CL submit itself the parameters truncated the spaces.  

    95 pointsBadges:
    report
  • ToddN2000
    If you are on an AS/400 or i-Series post a sample of the code in question. The thing that matters is the text being right or left justified. Try running the program in debug mode and see what is actually getting loaded to the parameters and it's justification.
    133,595 pointsBadges:
    report
  • MariaMYD
    It loaded to the CL perfectly with all the right characters string.  Somehow when I submit the job, the 77 characters one truncated the spaces. 
    95 pointsBadges:
    report
  • Splat
    One way around it would be, assuming you're not using it for anything else, to load the parameters into the *LDA extracting them when the job is running in batch.
    12,895 pointsBadges:
    report
  • ToddN2000
    It's not unusual for a lot of apps and programs to trim the trailing blanks. If there is nothing there it does not matter or prevent the job from running correctly. I'm kind of glad it does. We have a few jobs that pass out item configuration string. That is 998 characters in length. (why not make it an even thousand) For about 98 percent of our products it rarely goes beyond 200. I'd hate to see the other 798 being shown if they were blank. And ID hat to have to count out the others if I was testing manually and had to key all 998.   
    133,595 pointsBadges:
    report
  • MariaMYD

    I need all the spaces for each string to print on my letter.  When the string is truncated my letter come out with wired result.

    For example:  Name = 'IT KNOWLEGE EXCHANGE'  Address = ' 275 Grove Street'

    I want to print them in a separate line but they were printing side by side.  That's not acceptable.   

    I got the work around for now.  I put the value from the prompt screen to a work file.  When I submit I don't pass any parameters.  Load the value to the RPG program to print on my letters.

    I want to know why more since I got my work around because I used this a lot and this is the first time ever happened to me.




    95 pointsBadges:
    report
  • TheRealRaven
    This is standard (documented) behavior, though it can take a bit of experience to understand fully.

    There are three ways to approach the problem. First (not a good idea) is to pass one extra byte. Second is to create a *CMD as a 'prototype' for the called program. Third is to use SBMJOB correctly.

    For the first, it gets into a habit of more or less lying to the system, and subsequent maintenance developers, about what the proper parameter values are. When later scanning for parameter mismatches, trouble follows. But it can 'work'.

    For the second, this is the long term intended method. By creating the *CMD 'prototype', many errors can be reduced or minimized. The system can check for many parameter errors either at source-edit-time or compile-time. If constants are passed for parameters, they can be converted to the specific data types and lengths needed. When CALL is submitted through SBMJOB, even variables in the submitting program necessarily become constants.

    For the third, the proper way to pass constant parameter values through SBMJOB into a CALL command is via the RQSDTA() parameter and not the CMD() parameter. The CMD() parameter is intended for when a *CMD object has been created.

    The CMD() parameter didn't originally exist. It was added after too many novice developers disliked the rules of quoting string values and the rules for decimal values of the system's CALL command. But if you specify a 77-char quoted string even with trailing blanks in RQSDTA(), the resulting parameter value will be 77 chars with blanks retained.

    RQSDTA() is the actual command string that gets passed. What you put into the CMD() parameter is first processed by the command analyzer and put into RQSDTA() form. This includes such things as trailing-blank truncation. If you create the RQSDTA() yourself, you're indicating to the system that you know exactly what you want and it shouldn't be modified. The CMD() value only exists while SBMJOB executes; the RQSDTA() value becomes the submitted job.

    You might test attempts by specifying a false program name on the SBMJOB command. This causes the job to fail, but the failing joblog can show the actual "request data" that passed. Once you're satisfied with the test, the code can be put into the production program.
    35,610 pointsBadges:
    report
  • ToddN2000
    @MariaMYD: if this id for printing purposes, how are you printing the file? Via an RPG program or another method? You could always load  a carriage return at the end of each parameter to force a new line.  Without seeing the code on how it's being used to print, we can only guess at possible solutions. 
    133,595 pointsBadges:
    report
  • MariaMYD


      

    First - program call CL.


    The parameters come in with their string value.

    CALLP MBTRSFC (&TYP &SLD &CUT &NAM &AD1 &AD2 &AD3 &AD4 &AD5 &AD6)  



    95 pointsBadges:
    report
  • MariaMYD

    CL will received the parameters.  Debug showed with spaces.

    PGM PARM (&TYP &SLD &CUT &NAM &AD1 &AD2 &AD3 &AD4 &AD5 &AD6)      

                                                                                                     
    DCL        VAR(&TYP) TYPE(*CHAR) LEN(3)                       
    DCL        VAR(&SLD) TYPE(*CHAR) LEN(1)                       
    DCL        VAR(&CUT) TYPE(*CHAR) LEN(8)                       
    DCL        VAR(&NAM) TYPE(*CHAR) LEN(77)                      
    DCL        VAR(&AD1) TYPE(*CHAR) LEN(77)                      
    DCL        VAR(&AD2) TYPE(*CHAR) LEN(77)                      
    DCL        VAR(&AD3) TYPE(*CHAR) LEN(77)                      
    DCL        VAR(&AD4) TYPE(*CHAR) LEN(77)                      
    DCL        VAR(&AD5) TYPE(*CHAR) LEN(77)                      
    DCL        VAR(&AD6) TYPE(*CHAR) LEN(77)                      
    DCL        VAR(&JTP) TYPE(*CHAR) LEN(1)                       
                                                                  
    RTVJOBA    TYPE(&JTP)                                         
                                                                  
    IF         COND(&JTP = '1') THEN(DO)                          
    SBMJOB     CMD(CALL PGM(MBTRSFC) PARM(&TYP &SLD &CUT &NAM &AD1 &AD2 &AD3 &AD4 &AD5 &AD6)) JOB(MBTRSFC)                                    
    GOTO       CMDLBL(ENDPGM)                                    
    ENDDO                                                        
                                                                 
    CLRPFM     FILE(MBTRSFWRK)                                   
    CALL       PGM(MBTRSFRS) PARM(&TYP &SLD &CUT &NAM &AD1 &AD2 &AD3 &AD4 &AD5 &AD6)                            

    95 pointsBadges:
    report
  • ToddN2000
    @MariaMYD: The code you posted looks fine  How are you printing the data, from an RPG program or an app written in something like VB, C#, C++, PHP or some other language? Post the code and output specs. if it's not breaking on each parm for the address it should be a simple fix.

    133,595 pointsBadges:
    report
  • MariaMYD

    SQLRPGLE program passing in using DCL-PR and DCL-PI.  I want to post it but the editor won't allow me.

    95 pointsBadges:
    report
  • MariaMYD

    BELOW is how I print my report.

    open MBTRSFWRK;            
    read MBTRSFWRK;            
    DOW not %EOF(MBTRSFWK);   
        write ptrsf1;          
        write ptrsf2;          
    read MBTRSFWRK;            
    ENDDO;                     
    close MBTRSFWRK;           



    95 pointsBadges:
    report
  • ToddN2000

    @MariaMYD: What is the page size of your spool file and what do the Output specs look like for your write commands? If you do not have Output specs I assume you have a predefined print file. Post the definition of the code that shows where your fields are to be printed.

    : What is the page size of your spool

    133,595 pointsBadges:
    report
  • MariaMYD
    PRINTER DEVICE TYPE . . . . . . . . . . : DEVTYPE   *SCS
    PAGE SIZE / WIDTH . . . . . . . . . . . :       66 / 132
    LINES PER INCH . . .  . . . . . . . . . : LPI          6
    CHARACTERS PER INCH . . . . . . . . . . : CPI         10
    OVERFLOW  . . . . . . . . . . . . . . . : OVRFLW      60
    DEGREE OF PAGE ROTATION . . . . . . . . : PAGRTT   *AUTO
    DRAWER  . . . . . . . . . . . . . . . . : DRAWER       1
    HOLD SPOOLED FILE   . . . . . . . . . . : HOLD      *YES
    SAVE SPOOLED FILE   . . . . . . . . . . : SAVE      *YES
    95 pointsBadges:
    report
  • MariaMYD

    Here is the output spec.

    A            INAME         77     27  2    
    A            INAME1        77     28  2    
    A            INAME2        78     29  2    
    A            IADD1         77     30  2    
    A            IADD2         77     31  2    
    A            IADD3         77     32  2    
    A            IADD4         77     33  2    
    A            IADD5         77     34  2    
    A            IADD6         77     35  2    

    95 pointsBadges:
    report
  • TheRealRaven
    Change your program to include these lines:
    dcl        &q          *char             value('''')
    dcl        &cmd        *char len( 604 )
    
    chgvar     &cmd       ( 'CALL PGM(MBTRSFC) PARM(' +
                            *cat &q *cat &TYP +
                            *cat &q *bcat &q *cat &SLD +
                            *cat &q *bcat &q *cat &CUT +
                            *cat &q *bcat &q *cat &NAM +
                            *cat &q *bcat &q *cat &AD1 +
                            *cat &q *bcat &q *cat &AD2 +
                            *cat &q *bcat &q *cat &AD3 +
                            *cat &q *bcat &q *cat &AD4 +
                            *cat &q *bcat &q *cat &AD5 +
                            *cat &q *bcat &q *cat &AD6 +
                            *cat ')' )
    
    SBMJOB     RQSDTA ( &cmd ) JOB(MBTRSFC)
    The two new DCLs are for building the RQSDTA() command string. The request command is built with the CHGVAR command. And the SBMJOB command now uses RQSDTA() with an appropriately structured CALL command with quoted parms that are longer than the default 32-char length with trailing blanks.
    35,610 pointsBadges:
    report
  • WoodEngineer
    It would be helpful to see the SBMJOB exactly as in the CL.
    Keeping those trailing spaces can be a challenge.
    8,225 pointsBadges:
    report
  • WoodEngineer
    I apologize . . . did not look far enough into the responses. 
    8,225 pointsBadges:
    report
  • jamesdroke
    Great job TheRealRaven.
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: