Thursday, June 3, 2010

Sub Valued Level Prompting Details

How do you fixup the screen and do cross referencing and other validations when you use SUB.VALUE.PROMPTING on a SUB.MT500 screen?

Here is an example where we want to prompt for multiple file names and within each file for multiple item ids.

Instead of calling SUB.VALUE.PROMPTING directly from the SCREEN, call your subroutine which in turn will call SUB.VALUE.PROMPTING.
















Remember to add right justified fields using the PWS screen in SCREEN.BUILD if you want the count of sub-valued items to line up nicely.


You can add logic to execute only at the sub-valued level by checking X_Data_2 for the FROM.SCROLL.MAINT flag.

*

2200* Before prompt logic for Item_Attachments

*

IF INDEX(Prompt.X_Data_2, 'FROM.SCROLL.MAINT', 1) > 0 THEN

* Handle inner event from SUB.VALUE.PROMPTING execution of SCROLL.MAINT

* Reset SIP.VAL.FILE to enable cross referencing

FILE.VALUE = FIELD(Prompt.Display_Text_2, ",", 2)

FILE.LIST = MAIL.FILE.File_Attachments

CURRENT.FILE = FILE.LIST<1,FILE.VALUE>

CALL GET.DB.FILE(SIP.VAL.FILE, CURRENT.FILE)

ERROR = 0

RETURN

END

* Handle MAILBOX.ATT prompt event

GOSUB 2210;* Fixup Prompt Label with SUB.VALUE level display text

* Setup XREF stuff

Prompt.Conversions_Edits = '0X':@SVM:Prompt.Conversions_Edits

* remove compiled edits to force recompile

Prompt.Conversions_Edits = FIELD(Prompt.Conversions_Edits,roiDataMark4,1)

CALL GET.DB.FILE(SIP.VAL.FILE, CURRENT.FILE)

CALL SUB.VALUE.PROMPTING(ANSWER,SUB.DATA,P.NBR,PMT,SAVE.FN,VALUE)

END

*

RETURN

If you want to fix up details like the screen labels and prompt text while at the sub-valued level you can do this sort thing:

*

2210* Display SubValue Level Label Text

*

SET.NBR = Prompt.Scroll_Field_Type[2,2]

LOCATE SET.NBR IN SCROLL.DATA<9,1> SETTING PRIMARY.IDX ELSE RETURN

PRIMARY.PMT.NBR = SCROLL.DATA<1,PRIMARY.IDX>

PRIMARY.PMT = PID(PRIMARY.PMT.NBR)

STARTING.ROW = PRIMARY.PMT<1,7>

HEAD.ROW = STARTING.ROW-1

DISP.MASK = "L#":Prompt.Display_Length

ID.LABEL = XLATE("DICT ":CURRENT.FILE, "F0", 61, "X")

IF ID.LABEL = "" THEN ID.LABEL = "Item Id"

LABEL.TEXT = FMT(P.NBR,"2\0R"):".":VALUE:' ':ID.LABEL

Prompt.Text = "Enter ":ID.LABEL

REDIS.MISC<10> = L(HEAD.ROW):C(PMT<1,6>):LABEL.TEXT DISP.MASK

PRINT REDIS.MISC<10>:

RETURN

For Validation after prompting you can check the X_DATA_2 flag again and if you are at the multi-valued level simply request a repaint with ERROR=1000, but at the sub-valued level actually carry out input validations programmatically. Remember that your sub-valued level validation logic is being called from SCROLL.MAINT so do not use ERROR codes like 200, 1000 as you would for SUB.MT500, simply 0 or 1.

*

3200* After prompt logic for Item_Attachments

*

IF INDEX(Prompt.X_Data_2, 'FROM.SCROLL.MAINT', 1) = 0 THEN

* Remove SV Label Text

REDIS.MISC<10> = ''

ERROR = 1000

END ELSE

IF NOT(SIPDATA) THEN RETURN

FILE.VALUE = FIELD(Prompt.Display_Text_2, ",", 2)

FILE.LIST = MAIL.FILE.File_Attachments

CURRENT.FILE = FILE.LIST<1,FILE.VALUE>

REC = XLATE(CURRENT.FILE, ANSWER, -1, 'X')

IF REC = '' THEN

* Message 502: %1 item %2 not on file

CALL SCREEN.MSG(GetMessageText(502,CURRENT.FILE:@VM:ANSWER,0):";H;#M446065")

ERROR = 1

END

END

RETURN

No comments: