Page 1 of 1

Binding column heading to variable not working

Posted: Tue Oct 13, 2020 11:52 am
by Theju112
Dear Scott and Team,

I have an issue while trying to bind a subfile column heading list to a variable.

So , below is how I have used the variable (ColumnHead):

[img]
Capture.JPG
Capture.JPG (115.78 KiB) Viewed 911 times
[/img]

The RPG code is as below:

Code: Select all

ColumnHead = 'Ln#,Sts,Customer,Origin,,'+                    
             'Cons,Container,BOL#,'+                         
             'Booking,Plan,Order,P/U,Ship,Time,'+ [b]HDiff[/b] +    
             ',OM' ;                                         
                                                             
              EXFMT     LDSA1W     



The issue is with Hdiff variable which is a string that will hold a dynamic value. The issue is that, the first time, the subfile grid is displayed, the headings are displayed as required. Then in the scenarios where the screen is re-loaded after a different value (The only variable element in this case is the Hdiff field) is assigned, the old heading column values persist.

In summary, the value assigned to the ColumnHead variable when the first Exfmt is done persists even when the next Exfmt with a different ColumnHead value is done.

Are the headings not refreshed each time, the exfmt is done?

Re: Binding column heading to variable not working

Posted: Tue Oct 13, 2020 1:25 pm
by DanD
Are you sure that you have the code in the proper place? (Do you do EXFMT LDSA1W anywhere else?)

I don't know your logic - but it would seem to me that you'd want to assign the column headings at the time that you build grid (subfile) LDSA4W.

Good luck

Re: Binding column heading to variable not working

Posted: Tue Oct 13, 2020 2:22 pm
by Scott Klement
Each time you do EXFMT, the entire record format is wiped out and re-drawn, so the column headings are definitely re-done.

Here's an example that works for me... display file named COLHDGD:

Code: Select all

     A          R SFL                       SFL
     A            QPUI000001     1A  O  2  2
     A            NUM            5S 0H
     A            TEXT        1000A  H
     A          R QSFLCTL001                SFLCTL(SFL)
     A                                      SFLSIZ(0001)
     A                                      SFLPAG(0001)
     A                                      SFLDSP
     A                                  1  2HTML('QPUISFLCTL')
     A          R CTL
     A                                  1  2HTML('QPUICTL1    SFL       5    RS-
     A                                      FLDSP    0     RSFLDSPCTL 0     RSF-
     A                                      LCLR    0    FCLEARSFL  RSFLPAG    -
     A                                      1    C1    5 RSFLSIZ    1    C1    -
     A                                      6 0    0    ')
     A                                  1  2HTML('{"screen":{"record format nam-
     A                                      e":"ctl"},"items":[{"id":"Grid1","f-
     A                                      ield type":"grid","css class":"blue-
     A                                      print-grid","left":"35px","top":"90-
     A                                      px","number of rows":"6","number of-
     A                                       columns":"2","column widths":"100,-
     A                                      386","column headings":{"fieldName"-
     A                                      :"ColumnHead","dataLength":"500","t-
     A                                      rimLeading":"false","trimTrailing":-
     A                                      "true","blankFill":"false","rjZeroF-
     A                                      ill":"false","dataType":"char","for-
     A                                      matting":"Text","textTransform":"no-
     A                                      ne"},"header height":"35","row heig-
     A                                      ht":"35","height":"210px","width":"-
     A                                      487px","css class 2":"blueprint-def-
     A                                      aults","visibility":"visible","bord-
     A                                      er color":"transparent","record for-
     A                                      mat name":"sfl","clear subfile":{"f-
     A                                      ieldName":"ClearSFL","customTrue":"-
     A                                      ","customFalse":"","dataType":"indi-
     A                                      cator","formatting":"Indicator","in-
     A                                      dFormat":"true / false"}},{"id":"Ou-
     A                                      tputField1","field type":"output fi-
     A                                      eld","css class":"outputField","val-
     A                                      ue":{"fieldName":"num","dataLength"-
     A                                      :"5","decPos":"0","numSep":"false",-
     A                                      "zeroBalance":"false","numBlankFill-
     A                                      ":"false","zeroFill":"false","noExt-
     A                                      raSpaces":"false","curSym":"","data-
     A                                      Type":"zoned","formatting":"Number"-
     A                                      ,"negNum":"-999.00","units":"","des-
     A                                      ignValue":"[num]"},"left":"0%","top-
     A                                      ":"5px","css class 2":"blueprint-de-
     A                                      faults","css class 3":"blueprint-ou-
     A                                      tput-field","width":"100%","grid":"-
     A                                      Grid1","column":"0"},{"id":"OutputF-
     A                                      ield2","field type":"output field",-
     A                                      "css class":"outputField","value":{-
     A                                      "fieldName":"text","dataLength":"10-
     A                                      00","trimLeading":"false","trimTrai-
     A                                      ling":"true","blankFill":"false","r-
     A                                      jZeroFill":"false","dataType":"char-
     A                                      ","formatting":"Text","textTransfor-
     A                                      m":"none","designValue":"[text]"},"-
     A                                      left":"0%","top":"5px","css class 2-
     A                                      ":"blueprint-defaults","css class 3-
     A                                      ":"blueprint-output-field","width":-
     A                                      "100%","grid":"Grid1","column":"1"}-
     A                                      ]}')
     A            CLEARSFL       1A  H
     A            COLUMNHEAD   500A  H 
RPG program that runs the display is named COLHDGR:

Code: Select all

**free

ctl-opt dftactgrp(*no) option(*srcstmt:*nodebugio);

dcl-f colhdgd workstn handler('PROFOUNDUI(HANDLER)')
                      sfile(SFL:RRN);

dcl-s RRN packed(4: 0);

ClearSFL = *on;
write CTL;
ClearSFL = *off;
RRN = 0;

ColumnHead = 'Count,Fruit Name';
writeRow( 25: 'Apples');
writeRow( 19: 'Oranges');
writeRow( 12: 'Bananas');

exfmt ctl;

ClearSFL = *on;
write CTL;
ClearSFL = *off;
RRN = 0;

ColumnHead = 'Qty,Product';
writeRow( 15: 'Rich Display Licenses');
writeRow( 20: 'Genie Licenses');
writeRow(  6: 'Profound.js Licenses');

exfmt ctl;

*inlr = *on;

dcl-proc writeRow;

  dcl-pi *n;
    n packed(5: 0) const;
    t char(1000)    const;
  end-pi;

  RRN += 1;
  num = n;
  text = t;
  write SFL;

end-proc;
 
When I run it, it looks like this:
firsthdg.png
firsthdg.png (7.51 KiB) Viewed 897 times
After hitting enter, it changes the column headings and looks like this:
secondhdg.png
secondhdg.png (10.16 KiB) Viewed 897 times
Please tell me what I should change to experience the same problem you're having.

Re: Binding column heading to variable not working

Posted: Tue Oct 13, 2020 11:39 pm
by Theju112
Hi Scott,

Thanks for your guidance. I was able to get it working after moving the ColumnHead variable assignment before writing to LDSA4W.
Sorry should have thought of that.

I felt that the record format is not being re-drawn because the assignment before the Exfmt (which I showed in the code) worked in the first instance but not for subsequent executions of the same line. And yes, this is the only Exfmt in the whole program.

The program was put in debug mode with a breakpoint on the line with the Exfmt and I "manually" assigned a value to columnHeading (using Eval) before doing an F10. The column heading showed the value I assigned. Please note that there were no write operations done in between the "manual value assignment" and the Exfmt.

But when the control reached the Exfmt the second time and I tried the same, it didn't work. The previous heading was still displayed. So that was a bit confusing.

Anyways, thanks a ton for your quick response!!