Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apostrophes in parameter data

Status
Not open for further replies.

SuzieW

Programmer
Dec 17, 2002
41
0
0
GB
Hi all

I have a problem with apostrophes!

I have a S36 file (don't ask!) with a native AS400 RPG trigger program attached to it which fires after an insert or update.

The trigger program then submits a job (using QCMDEXC), calling another RPG program and passing it the trigger buffer as a parameter.

The problem comes when one of the subfields of the trigger buffer contains an apostrophe - the SBMJOB statement fails because it interprets the apostrophe as a delimiter rather than an apostrophe.

So my idea was, in the trigger program, to scan and replace the single apostrophe with two as I've read that this is the way to get an RPG to recognise a single apostrophe.

It worked to an extent - the SBMJOB statement was successful, but by the time the data hit the second RPG program, there was only one apostrophe and all the subsequent subfields in the trigger buffer had been shunted back one, which screwed the rest of the data.

Any ideas why it is doing this?

Is there any way I can retain my apostrophe, or should I just give up and replace it with a space? The field in question is an address line, so it's quite valid for there to be an apostrophe in it...
 
Hmm... Not sure but try to add an extra apost, that is add 1 apost more everywhere you're using 2 (yes, three in all). If it doesn't work pls paste the SBMJOB command here.
 
Hi Mercury2

Tried it with the three - back to square one (i.e. falling over on the SBMJOB with "Character 'B' not valid following string ''692601120', A matching apostrophe not found).

When I use the "two apostrophe" method, there are definitely two apostrophes when the data is passed to the second program (from joblog):

Message . . . . : -CALL PGM(P800B) PARM('6926021801400TRIDENT
011500150001008949501ABBBLN O''BLUNHAM, DM140708
MQ120 90086054356 ON19/11/0751235TRIDENT 01
M512350000 03
')

But on the dump from the second program (which fails with Decimal Data Error), there is only one in the subfield.

OECUSTTW CHAR(15) 'O'BLUNHAM, D'

and, as you can see, that D from the next field has crept in.

Ahhh, the joys of apostrophes...
 
Try using the " instead of 2 ' charaters. That's the upper shift " as a single character. While command processing sometimes changes this to a single ', usually in data its left alone.
 
Code:
PARM('6926021801400TRIDENT                  
        011500150001008949501ABBBLN         O[highlight #FF99FF]'[/highlight]''BLUNHAM,    DM140708            
       MQ120 90086054356     ON19/11/0751235TRIDENT                       01    
       M512350000                                                  03          
                                  ')
Just add the sole highlighted apost above and give it a try pls. This is what I meant by three apost's.
 
Mercury - that's what I tried, but the call to QCMDEXC fell over with "A matching apostrophe not found..." (i.e. the same error as when there is just one apostrophe).

arrow483 - thanks, I'll try that and see what happens



 
A matching apostrophe not found..."
I hate that message. It's definitely a pain in the *** for all the iSeries Community
demon.gif
 
Im just gonna pasta a little snippet of code to let you know what you are up against.

Code:
            cmdStr = 'SBMJOB CMD(CALL PGM(pgm1) PARM(''' +
            %char(number1) + ''' ''' +
            %char(number2) +  ''' ''0'')) '  +
            'JOB(setValue' + %char(i) + ') ' +
            'SCDTIME(''' + %xlate('.':':':%char(timenumber)) +''')';

after this cmdStr is:

SBMJOB CMD(CALL PGM(pgm1) PARM('2' '1' '0')) JOB(setValue)SCDTIME('16:00:00')


I would suggest you to debug and check what string you send into qcmdexec. From there on its trial and error :)
Im not 100% on apostrophes but I would try your string with both 4 and 5 apostrophes where you had highlighted, or possibly following : ' + ''' + '

- - - - - - - - - - - - - - - - - -
Im three apples high, Im blue, and I really like that cold beer that should be every mans right after a hard days work!
 
arrow - the double quote " worked fine - nothing fell over. But I was left with a double quote in my destination data, when what I'd really like is an apostrophe :eek:)

smurf - tried with four and five - both caused it to fall over with the "Matching apostrophe...". It builds the SBMJOB command okay, but as soon as it calls QCMDEXC, it bails out.

I think I'm going to have to just take the apostrophe out and put a space in (or a double quote).

C'mon, whose idea was it to use an apostrophe as a string delimiter? Causes no end of problems...

 
Suzie,
You can populate the local data area (*LDA) with the trigger buffer, remove the parameter from the SBMJOB and retrieve the locale data area in the batch job as it is copied from the interactive job. This is certainly much easier to setup and you don't alter the parameter value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top