5250 Changes

Topics: Developer Forum, User Forum
Dec 30, 2010 at 4:32 PM

Is there anything special I need to do to make this work with a 5250 connection?  I guess the best question would be is does this work with a 5250 terminal?  I can connect but functions keys and some chars like < do not work or show up correctly on screen.


Brad West

Dec 30, 2010 at 6:09 PM
I have never used the 5250 protocol, though I don't imagine it is all that dissimilar. However, you would need to go into the Telnet code and make the necessary cahnges, as this is designed for 3270 communications, not 5250.

From: bradstarbuckwest [email removed]
Sent: Thursday, December 30, 2010 10:33 AM
To: Jason Coffee
Subject: 5250 Changes [Open3270:240013]

From: bradstarbuckwest

Is there anything special I need to do to make this work with a 5250 connection? I guess the best question would be is does this work with a 5250 terminal? I can connect but functions keys and some chars like < do not work or show up correctly on screen.


Brad West

This message contains information which is privileged and confidential and is solely for the use of the
intended recipient. If you are not the intended recipient, be aware that any review, disclosure,
copying, distribution, or use of the contents of this message is strictly prohibited. If you have
received this in error, please destroy it immediately and notify us at PrivacyAct@torchmarkcorp.com.
Dec 31, 2010 at 4:12 AM

Any assistance would be helpful on this subject.  I have done alot of comparing of 5250 and 3270.  I found there isn't much of a difference even in the connection.  I just cannot find the small difference that makes the function keys work correctly.  Alpha and numeric keys work correctly, Enter and Tab keys work correctly, but the function keys do not correspond to the display.  F1 key shows details about messages but the rest just give the error Function Key not definied on the screen when F3 should be Exit.  Suggestions?

Feb 3, 2011 at 1:02 PM

Hi bradstarbuckwest.

I got the same problem last week.
It turns out that this 3270-client can communicate with a 5250 pretty good.
But on the 5250 mainframeside they usually have a default "3270 key map" that maps the first 12 function keys to other functions (see the dump just below).

*************** Dump ********************
   0         1         2         3         4         5         6         7        
0                       Help for 3270 Keyboard Mapping                            
2   3270 Key                                   3270 Key                               
3   Sequence   Function                    Sequence   Function                    
4     PF1        5250 help text                PF13        F13                         
5     PF2        3270 help text                PF14        F14                         
6     PF3        Clear display                   PF15        F15                         
7     PF4        Print display                    PF16       F16                         
8     PF5        Display attributes            PF17       F17                         
9     PF6        Test request                    PF18       F18                         
10   PF7        Page up (Roll down)        PF19       F19                         
11   PF8        Page down (Roll up)        PF20       F20                         
12   PF9        Attention                        PF21       F21                         
13   PF10      Error reset                       PF22       F22                         
14   PF11      System request               PF23       F23                         
15   PF12      Record backspace            PF24      F24                         
17  Display attributes = display imbedded attributes                              
20  Press Enter to continue.                                                      
21                                                                    More...     
22  F3=Exit     F12=Previous                                                      


So this is why the F1-F12 dosen't work as you want.
Your 5250 mainframe can ofcause have a different 3270 mapping then this one, so look it up, "press F2" in Open3270 and look at the emulator.CurrentScreenXML.Dump() after you have done a waitfortext and you should see something similar to my mapping. 
You can actually by pass this mapping table by pressing PA1 key before the F# key, then it will work.
But this Open3270 have some synchronization problem with making it work when you press the PA1 button before the F# button.

So there is two easy solusions to this.
1. Call the 5250 guys and tell them to change the 3270 mapping for all users, or make a script that change it for a specific user(your user).
2. Or make some small changes to the Open3270 sourcecode to make it work with a 5250.


The changes I had to make to make this work was:

I created a own 5250TNEmulator that inherit from the TNEmulator (Open3270).
And changed the functionheader for the function "SendKeyFromText" in the TNEmulator (Open3270) so I can override the function in my class (added "virtual" to it).

Old functionheader TNEmulator (Open3270)
public bool SendKeyFromText(bool WaitForScreenToUpdate, string text, int timeout)

New functionheader TNEmulator (Open3270)
public virtual bool SendKeyFromText(bool WaitForScreenToUpdate, string text, int timeout)

This is is the code for my 5250TNEmulator that override the function and send a a PA1 before the PF function that are remapped .

************* Code ****************

using System;
using System.Collections.Generic;
using System.Text;
using Open3270;

namespace 5250fixOpen3270
    /// <summary>
    /// A specific emulator for 5250 communication, inherit the TNEmulator.
    /// </summary>
    public class 5250TNEmulator : TNEmulator

        /// <summary>
        /// Sends a key to the host. Key names are:
        /// Attn, Backspace,BackTab,CircumNot,Clear,CursorSelect,Delete,DeleteField,
        /// DeleteWord,Down,Dup,Enter,Erase,EraseEOF,EraseInput,FieldEnd,
        /// FieldMark,FieldExit,Home,Insert,Interrupt,Key,Left,Left2,Newline,NextWord,
        /// PAnn, PFnn, PreviousWord,Reset,Right,Right2,SysReq,Tab,Toggle,ToggleInsert,ToggleReverse,Up
        /// This function is Overrided so we can send correct AID to IBM 5250 from this 3270-client code
        /// </summary>
        /// <param name="WaitForScreenToUpdate"></param>
        /// <param name="text">Key to send</param>
        /// <param name="timeout">Timeout in seconds</param>
        /// <returns></returns>
        public override bool SendKeyFromText(bool WaitForScreenToUpdate, string text, int timeout)
            if (text.Substring(0, 2) == "PF")
                int PfNumber = System.Convert.ToInt32(text.Substring(2));
                if (PfNumber >= 1 && PfNumber <= 12) // if the PfNumber is 1,2,3,4,5,6,7,8,9,10,11,12 then do this special code
                    // PF 1-12 is assigned to other functions then the correct Pf keys for a 3270-client to 5250 mainframe
                    // We need to press the PA1 key before we can send the PF key so it connect to the right function/key
     // We need to send a timeout to the functionn, otherwise it will send the PF key too fast to the mainframe
                    if (timeout == 0)
                        timeout = 250;

                    // first send a PA1 code so it will switch to right mapping for PF keys
                    if (!base.SendKeyFromText(WaitForScreenToUpdate, "PA1", timeout))
                        return false; // if the SendKeyFromText returned false, then breake and return false
                    // Then send the PF key.
                    if (!base.SendKeyFromText(WaitForScreenToUpdate, text, timeout))
                        return false; // if the SendKeyFromText returned false, then breake and return false

                    return true; // return true if everything was ok.
     // if the PF number was not one of the PF keys are remapped then use the normal SendKeyFromText
                    return base.SendKeyFromText(WaitForScreenToUpdate, text, timeout);
    // if the AID key was not a PF key then use the normal SendKeyFromText
                return base.SendKeyFromText(WaitForScreenToUpdate, text, timeout);

**************** End code **********************

Your other problem with the chars have a different solution, I had some char problems too, the swedish character "ö" , its an "o" with two dots over it, was translated to a space " ". That was also solved by some more changes to the code, inherit and override once again :)
Just post in this thread and I will get an e-mail, and we see if we can solve this problem too for you.

Mar 3, 2011 at 2:49 AM

Completely amazing.  I will get right on making changes to this.  I will get you the char problems when I find them.  The biggest problem is the < and > chars.  Thanks so much for your help.

Mar 4, 2011 at 12:36 AM

I don't believe this is a sending problem but it is a translation problem comming back.  It has something to do with '>' (&gt;).  The weird part is that '<' (&lt;) comes back fine.  I have found a few place where '>' is commented out.  If I put them back in or have them translate like '<' I get an unknown error.  I will get a stack trace and maybe that will help.  Could there be something else I am missing?  It just doesn't seem like all of the XML codes are being translated correctly on the way back.


Brad West