Conditional code block in template

Pavlo

Member²
Hello I'm trying to insert a conditional code block in a program unit template. So I created an query which gives me the wanted code block. Then I tryed to insert it in my code. My example:

[$QUERY EDITASK = SELECT
' ELSIF (REC_AKTION.AKTIONNR = ) THEN

-- Aktion 2: EDI-Task vom Typ anlegen
EVENT_CREATE_EDITASK_B('''',
REC_AKTION.DOCTYP,
REC_AKTION.KUNDENNR,
REC_AKTION.DOCFUNKTION,
REC_AKTION.DOCNR,
REC_AKTION.DOCPOSNR,
REC_AKTION.DOCTYP,
REC_AKTION.TR_STATUS,
REC_AKTION.EVENTNR,
REC_AKTION.AKTIONNR,
REC_AKTION.EAENR,
iIsTRet);

IF (iIsTRet = 0) THEN
iStat := PU_SYNO.ST_EVENT_GESCHLOSSEN;
ELSE
iStat := PU_SYNO.ST_EVENT_FEHLER;
iIsRet := iIsRet + 1;
END IF;' BLOCK FROM DUAL]
..
..
..
[Edi Task wanted?=$EDITASK]

RESULT:
..
..
EDI-Task vom Typ anlegen
EVENT_CREATE_EDITASK_B(''
----------------------------------------------------

So how do I get the complete result from the query and how do I get an checkbox to select that i want this block?

Thanks for any help.
 
I would use this code:

Code:
&<name="ELSIF Block?" checkbox="""   ELSIF (REC_AKTION.AKTIONNR = <NR>) THEN

-- Aktion 2: EDI-Task vom Typ <TYPE> anlegen
EVENT_CREATE_EDITASK_B(''<TYPE>'',
REC_AKTION.DOCTYP,
REC_AKTION.KUNDENNR,
REC_AKTION.DOCFUNKTION,
REC_AKTION.DOCNR,
REC_AKTION.DOCPOSNR,
REC_AKTION.DOCTYP,
REC_AKTION.TR_STATUS,
REC_AKTION.EVENTNR,
REC_AKTION.AKTIONNR,
REC_AKTION.EAENR,
iIsTRet);

IF (iIsTRet = 0) THEN
iStat := PU_SYNO.ST_EVENT_GESCHLOSSEN;
ELSE
iStat := PU_SYNO.ST_EVENT_FEHLER;
iIsRet := iIsRet + 1;
END IF;""">

Note that because of the fact that the code contains commas, which would normally be interpreted as the separator between the 2 checkbox values, you need to enclose the value in 2 double quotes. For example:

Code:
&<name="Question" checkbox="""Yes, please"",""No, thanks""">

This is not very intuitive, so we'll enhance this.
 
Thanks.
That works. Is it also possible to use variables (Example &"Type" for '' in my source) in the conditional code block. So yes are they only requested if the checkbox is true?

Is there somewhere a list the the possible syntax of variables used in template? (&)
 
You cannot refer to other variable values in the checkbox text.

See chapter 27 ("Templates") in the User's Guide for a complete description of the template syntax. It refers to chapter 12.3 ("Variables") for the complete syntax reference of user variables.
 
We have added this feature for the next (14.0) release. You can then use a &variable expression in the checkbox values and list values.
 
Back
Top