Name string alignment in AS/400 printer file

2880 pts.
Tags:
AS/400
AS/400 Printer File
RPGLE
I have a customer name field of 240 length. There are four fields defined with 60 length in AS/400 printer file. I wanted to print the name in the printer file with character alignment(like not leaving a single letter in the end of the field). Is there any procedure/steps you can suggest me to do it RPGLE?
1

Answer Wiki

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

use the keywords CNTFLD and WRDWRAP in the DDS for the customer name field.

CNTFLD (Continued-Entry Field) keyword for display files

You use this field-level keyword to define a field as a continued-entry field.
Continued-entry fields are sets of associated entry fields that are treated by the workstation controller as a single field during field-data entry and editing. 

The format of the keyword is:
CNTFLD(width of column)
One parameter must be specified.
The width of the column parameter specifies the number of columns to be used for this continued field.
This value must fit within the width of the display or window. This value must be less than the length of the field.
The field containing the CNTFLD keyword must be defined as an input-capable field with the data type A. 
It cannot be defined in a subfile.

The following keywords cannot be specified on a field with the CNTFLD keyword:
* AUTO (RAB, RAZ)
* CHECK(AB, MF, RB, RZ, RLTB)
* CHOICE
* DSPATR(OID SP)
* EDTMSK

The CNTFLD keyword must be defined with at least 2 spaces separating it from other fields.

Option indicators are not valid for this keyword.

-------------------------------------------------

WRDWRAP (Word Wrap) keyword for display files

You use this file-level, record-level, or field-level keyword for continued-entry fields, or for named fields so that they overflow onto subsequent display lines.
The keyword causes wrapping to occur at a blank in the data rather than at the end of the data line. It is used to make long text fields easier to read. The default is for data to be wrapped at the end of the physical line or continued-entry field segment.

This keyword can only be specified on fields that have a usage of input-only (I) or input/output (B).

This keyword has no parameters.

You cannot specify the WRDWRAP keyword on the following keyboard shifts:
* Signed Numeric (S)
* Numeric Only (Y)
* Digits Only (D)
* Numeric Only Character (M)
* Floating Point (F)
* DBCS Only (J)
* DBCS Open (O)
* DBCS Either (E)
* Graphic (G)

WRDWRAP cannot be specified with the following keywords:
* AUTO(RAZ, RAB)
* CHECK(MF, M10F, M11F, RB, RZ, RL, RLTB)
* CHGINPDFT(MF)
* DSPATR(OID, SP)
* DUP
* FLTFIXDEC
* IGCALTTYP

Option indicators are not valid for this keyword.

When WRDWRAP is used, the field length is not increased. Therefore, if too much data is entered the word wrapping effect will be turned off.
Notes:

Subfiles do not support WRDWRAP.

-------------------------------------------------

Example
The following example shows how to specify the CNTFLD keyword:
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
A R RECORD
A F1 90A B 3 4CNTFLD(30)
A             WRDWRAP

In this example, a multiple-row entry field is defined. The entry field contains 3 lines and is 30 columns
wide and will have the benefit of word wrap.

Discuss This Question: 6  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.
  • philpl1jb

    // here is a rough draft

    //intent is to search for the last blank in 60 spaces

    //   put everything before that into the output array

    //   put everything after that into the wrkfld for the next loop  

    PosLast = 1;

    ArrayPos = 1

    wrkfld = completeNameFld;

    Dow ArrayPos <= 4 // load each of your four fields

    PosNext = %scan(' ' : wrkfld : PosLast); // find next space

    dow PosNext < 60;  // but we want the last space before 60

    PosLast = PosNext; // found a space under 60 use it for now

    PosNext = %scan(' ' : wrkfld : PosLast);  // find next space

    enddo;  // PosNext 

    Array(arrayPos) = %substr( wrkfld : 1: PosLast); //load printer field

    wrkfld = %substr( wrkfld : PosLast + 1   );  // drop used portion

    arrayPos = arrayPos + 1;  // get ready for next portion of name

    PosLast = 1;

    Enddo; // array position

    if wrkFld > ' '; // if there is anything in wrkFld then abandon all hope

       Array(1) = %substr(completeNameFld: 1: 60); //load printer field1

       Array(2) = %substr(completeNameFld:61:120);//load printer field2

       Array(3) = %substr(completeNameFld:121:180); //load printer f3

       Array(4) = %substr(completeNameFld:181:240); //load printer f4

    endif; //wrkfld > ' ';

    54,090 pointsBadges:
    report
  • NeilD

    1. Identify length of text in 240A (LongField) field:

    length = %len(%trim(LongField));

    2. Using that length, substring into the 60A (ShortField) field:

    evalr ShortField = %subst(LongField:1:length);


    570 pointsBadges:
    report
  • TheRealRaven
    What does "not leaving a single letter in the end of the field" mean? Some sample data and desired output would be useful.
    35,130 pointsBadges:
    report
  • Sureyz
    For ex. Customer Name is 
    MR MARK ZUKERBERG ON LEASE TO HONKONG AND SHANGHAI BANKING CORPORATION LTD
    
    I want to print this name in 5 fields(acc to cus name length) which having 38 length each.
    
    MR MARK ZUKERBERG ON LEASE TO HONKONG
    AND SHANGHAI BANKING CORPORATION LTD
    
    already find a solution by scan & check. But looking for a better answer.
    2,880 pointsBadges:
    report
  • ToddN2000
    If I understand you want to break up the name into multiple line but not splitting a word on 2 lines. If this is correct, how large is the field you are actually printing? You may have to scan for the blank spaces between words, and see if there is enough space left on the line to print it. It's just a lot of scanning and substringing and length testing.
    132,840 pointsBadges:
    report
  • Splat
    Here's a bit of code we're using for something similar:
    Work = field;                        
    Dou work = *blank;                   
     For pos = %len(print_fld) downto 1; 
      If %subst(work: pos: 1) = *blank;  
       Leave;                            
      EndIf;                             
     EndFor;                             
                                         
     Print_fld = %subst(work: 1: pos);   
                                         
     Exsr Print_01;                      
     Write(e) Print00001;                
                                         
     Work = %trim(%subst(work: pos));    
    EndDo;                               
    12,885 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: