Thursday, May 21, 2020

Setup mRemoteNG with SAP Gui Connections (auto logon)



I use and would recommend mRemoteNG to manage windows and linux servers for SSH and RDP access.
mRemoteNG offers more options and can be downloaded from the following link.




“It allows you to view all of your remote connections in a simple yet powerful tabbed interface.


mRemoteNG supports the following protocols:


RDP (Remote Desktop/Terminal Server)
VNC (Virtual Network Computing)
ICA (Citrix Independent Computing Architecture)
SSH (Secure Shell)
Telnet (TELecommunication NETwork)
HTTP/HTTPS (Hypertext Transfer Protocol)
rlogin
Raw Socket Connections”


This blog will use mRemoteNG external tools options to link to SAP GUI and setup a demo of auto logon

External tools reference link




Some version information on my system
SAPGUI = 760 Final Release,  7600.1.0.1156
mRemoteNG = 1.76.20.24615





The SAP system I will use in this blog is the SAP developer NPL edition.


Link mRemoteNG to SAPGUI


The process to link mRemoteNG is to use the External Tools feature to use the SAP Short Cut command for SAPGUI.


SAP GUI sapshcut


Checking the options offered by SAPGUI Shortcut with the help option


"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapshcut.exe" /help
(I have standard install following the standard install directory)






From the options in the screenshots those of interest are
-system=  -client -user= -pw=  -guiparm= 
This will enable the signon to the SAP NPL system via sapshcut
I will also use the -maxgui option maximise the gui.


Setup mRemoteNG External Tools with sapshcut


Check the mremoteng website for explanation of the external tools feature.




Important part is the variables that allow the configuration to use the sapshcut parameters to logon to SAP.


Variables

Variables and arguments can be used to tell the external tool what to do.
This is the list of variables supported by mRemoteNG:
  • %NAME%
  • %HOSTNAME%
  • %PORT%
  • %USERNAME%
  • %PASSWORD%
  • %DOMAIN%
  • %DESCRIPTION%
  • %MACADDRESS%
  • %USERFIELD%
As it is not an exact match I will use the following options to match up to the sapshcut parameters.

Standard Options
SAPSHCUT Parameter
mREMOTENG Variable
-system
%NAME% 
-client
%MACADDRESS%
-user
%USERNAME%
-pw
%PASSWORD%
-guiparm
%HOSTNAME% %DOMAIN%

** Special Character Passwords
USE the ! option as follows
-pw
%!PASSWORD%

For the SAP NPL system which has standard values for these parameters.


-system=NPL
-client=001
-user=developer
-pw=Down1oad
-guiparm=vhcalnplci 00


For guiparm it is important to leave a space between the hostname and instance number of the NPL system.
I found it is not possible to use mRemoteNG %PORT% variable as sapshcut expects two digits for the instance number e.g. using port 0 would not work for the instance number 00.


**For the password option -pw you need to decide if it is appropriate to fill in this value and consider password protecting the connection file with the following option.
The NPL developer password is a well known password so visible in this blog :).




Setup mRemoteNG External Tools
The mRemoteNG site linked earlier is useful to setup the external tools. 
The feature is under the Tools->External Tools menu


Select New


I use the following options




Display Name SAPGUI
Filename: C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapshcut.exe
Arguments: -system=%NAME%  -maxgui -client=%MACADDRESS% -user=%USERNAME% -pw=%PASSWORD%  -guiparm=%HOSTNAME% %DOMAIN%

***Remember to leave a space between hostname and instance number.

***Remember to adjust %PASSWORD% to %!PASSWORD% for any special characters in the password
Arguments: -system=%NAME%  -maxgui -client=%MACADDRESS% -user=%USERNAME% -pw=%!PASSWORD%  -guiparm=%HOSTNAME% %DOMAIN%

Setup a new connection with option Protocol = Ext. App and select SAPGUI (the name used for the external tool which will be a drop down action when external app is selected




Complete the connection entries for the NPL system




For the icon of the external tool I used an SAP ICO image as follows


SAP Icons web site
Link the the icon I downloaded


Copy the icon to the Icons mRemoteNG directory here (i used standard install locations)
C:\Program Files (x86)\mRemoteNG\Icons
You can then select this icon for the mRemoteNG connection (you may have to restart mRemoteNG to pick up the copied file)




Test the connection either double click the icon or right click and connect
*** dont forget to check SAP NPL is actually up and running :) or the system you have adapted these settings for ;)




If you used the password option you will be automatically logged on to NPL. Or the password will be prompted for the user defined.
For other system with multiple users or different clients you could create multiple connections for the clients/users required.

YouTube Video demonstration


Saturday, April 25, 2020

How to Print QRcodes, Data Matrix, Aztec Codes, Maxi Code and Han Xin Barcodes in SAP


Updated Device Types for Printing 2D Barcodes In SAP

Almost 10 years ago I published a blog that covered the process to print 2D Barcodes in SAP with the Barcode Writer In Pure Postscript, the following link focused on QR codes.

I have now updated some device types with the latest BWIPP code and combined 5 2D barcodes into one SAP device type. This allows all 5 standard variants of these barcodes to be printed in one process. I will publish further blog posts with dedicated device types for each individual 2D barcode later.

YouTube Video Demo




A change to the original blog is that I now use PDF24 as my barcode printer of choice rather than cutepdf.

The actual 2D barcode generation is still via integrating Terry Burton's Barcode Writer in Pure Postscript (BWIPP) project into SAP device types
BWIPP home page link - https://bwipp.terryburton.co.uk/

I will break down the process into the following steps.

1) Download the SAP 2D Barcode Device type and Example ABAP code here

Downloads also Available on GitHub https://github.com/rjruss/SAP_2DBarcodes_DeviceType

Extract the zip file and two files will be available

ZBWIPP2D = The SAP Device Type
Z2D_PRINT = demo ABAP code to print 2d barcodes

2) Import Device Type

Transaction SPAD & Select the below menu options to import the ZBWIPP2D device type

I am using SAP GUI 7.6 on my demo SAP NPL 7.52 trial system
Enter the Device Type NAME = ZBWIPP2D
Select Execute and a prompt will allow you to select the ZBWIPP2D.PRI file from the download



3) Install PDF24 

The PDF generator needs to process postscript so standard Windows 10 pdf printer is not sufficient for front end printing of these 2D barcodes from SAP.
SAP will send postscript output to be processed and PDF24 can do this for us. You can use CutePDF as well as other software, if you google there are a few options for this requirement to print postscript


PDF24 homepage
Download link

I used this version for my blog post but later versions can be used.

PDF24 Creator uses the free PDF interpreter Ghostscript , which is automatically installed as a private instance for the PDF24 Creator.

Following all standard options I have a PDF24 printer available


Check the following settings for PDF24 - there are many options but for this blog
Start PDF24 and select Settings


For this blog the settings are as follows- others are left as default


4) Create Output Device - in my example use the name FRONT2DC

Transaction SPAD -> Output Devices -> Display
Change to Edit mode and Create the following

Name = FRONT2DC 
Short Name = F2DC
Device Type = ZBWIPP2D    (created in step 2)

Host Spool Access Method = G: Front End Printing with Control Tech.
Host Printer = PDF24


Save

5) User defaults to print now so output will be processed immediately
(make sure it is set, log off and check it again :)

6) Import ABAP Demo Code 

From transaction SE38 create ABAP report Z2D_PRINT.
Cut and paste the text from the downloaded file Z2D_PRINT 

Activate - ignore any warnings for NEW-PAGE PRINT ON, this is purely used as a simple method to allow the ABAP code to use the printer controls in the device type.

Now run the report Z2D_PRINT


Select Output Device FRONT2DC (the device created in step 4)
Select the tick mark


Select OK to Print to PDF24 device.

Select “Save as PDF” in the PDF24 assistant screen.


7) The actual 2D Barcode PDF document should look something like this....



Adapt the code as required the print controls are key to create the barcodes.

Obviously the individual 2D barcodes can be printed independently of each other.




.

Saturday, February 1, 2020

SQL Server 2017 Always On in Disaster Recovery Scenario and Window 2016 servers in different subnets


Example setting up SQL Server Always On on a multi subnet network for disaster recovery scenario.


Following standard Microsoft documentation I found it specific to having Always On with 3 databases,
two an HA setup in one subnet and in addition a third server for DR in the other subnet.


My situation was a pure DR and only two database each in its own subnet. This is how
I tested the setup before implementing


Pre-Req for the following is my setup for the cluster and firewall rules I setup in this blog

Also not covered is the initial installation of SQL Server 17


My Always On setup
SQLA
10.10.10.35
SQLB
10.10.20.35
cluster - name - sqlcluster
10.10.10.86
10.10.20.86
Listener - name - sqlagl
10.10.10.87
10.10.20.87


Domain
RJRUSS.ORG
Users
Install - robert
Services - sqlserver


Setup Users
Users - robert, sqlserver - local admin group
Computer Management - Admin Group


*BOTH SQLA and SQLB updated


Enable HA & Update Service User for SQL Server 17


SQL Server Service








 
YES


SQL Server Agent User




BOTH SQLA & SQLB Services UPDATED


Backed UP Database on SQLA




Add Operating System Users to SQL Server SQLA & SQLB


Add robert,sqlserver logins to sysadmin and serveradmin in SQL server






Grant permissions to SYSTEM


USE master;
GO
GRANT ALTER ANY AVAILABILITY GROUP TO [NT AUTHORITY\SYSTEM]
GO
GRANT CONNECT SQL TO [NT AUTHORITY\SYSTEM]
GO
GRANT VIEW SERVER STATE TO [NT AUTHORITY\SYSTEM]
GO 


RAN ON BOTH SQLA & SQLB


PREPARE SQLB for RESTORE OF DATABASE


mkdir P3DDATA1/8 and LOG1 on sqlb




TEST CONNECTIONS with Databases SQL Server Management studio on SQLA connect to SQLB


Successful connection 


****************************************
**********I had connection errors before I was able to get a successful connection
**********only follow this SPN steps if the same error occurs
**********ERROR with SPN   --- maybe specific to my home lab - no issue with work env -- 
SQLA delete & recreate
C:\Users\robert>setspn -D MSSQLSvc/sqla.rjruss.org:1433 sqla
Unregistering ServicePrincipalNames for CN=SQLA,CN=Computers,DC=rjruss,DC=org
        MSSQLSvc/sqla.rjruss.org:1433
Updated object


C:\Users\robert>setspn -D MSSQLSvc/sqla.rjruss.org sqla
Unregistering ServicePrincipalNames for CN=SQLA,CN=Computers,DC=rjruss,DC=org
        MSSQLSvc/sqla.rjruss.org
Updated object


C:\Users\robert>setspn -A MSSQLSvc/sqla.rjruss.org:1433 RJRUSS\sqlserver
Checking domain DC=rjruss,DC=org


Registering ServicePrincipalNames for CN=sqlserver,CN=Users,DC=rjruss,DC=org
        MSSQLSvc/sqla.rjruss.org:1433
Updated object


C:\Users\robert>setspn -A MSSQLSvc/sqla.rjruss.org RJRUSS\sqlserver
Checking domain DC=rjruss,DC=org


Registering ServicePrincipalNames for CN=sqlserver,CN=Users,DC=rjruss,DC=org
        MSSQLSvc/sqla.rjruss.org


SQLB delete & recreate


C:\Users\robert>setspn -D MSSQLSvc/sqlb.rjruss.org:1433 sqlb
Unregistering ServicePrincipalNames for CN=sqlb,CN=Computers,DC=rjruss,DC=org
        MSSQLSvc/sqlb.rjruss.org:1433
Updated object


C:\Users\robert>setspn -D MSSQLSvc/sqlb.rjruss.org sqlb
Unregistering ServicePrincipalNames for CN=sqlb,CN=Computers,DC=rjruss,DC=org
        MSSQLSvc/sqlb.rjruss.org
Updated object


C:\Users\robert>setspn -A MSSQLSvc/sqlb.rjruss.org:1433 RJRUSS\sqlserver
Checking domain DC=rjruss,DC=org


Registering ServicePrincipalNames for CN=sqlserver,CN=Users,DC=rjruss,DC=org
        MSSQLSvc/sqlb.rjruss.org:1433
Updated object


C:\Users\robert>setspn -A MSSQLSvc/sqlb.rjruss.org RJRUSS\sqlserver
Checking domain DC=rjruss,DC=org


Registering ServicePrincipalNames for CN=sqlserver,CN=Users,DC=rjruss,DC=org
        MSSQLSvc/sqlb.rjruss.org


Setup CLUSTER 


Rebooted SQLB - to get Cluster IP back on .10. subnet




Waited for SQLB - to be back online


Setup Quorum on Cluster - as this is DR it will always be a manual FAILOVER scenario on no
votes for SQLB in the primary setup - only SQLA will have the vote




Change the assigned votes - More Actions - Configure Cluster Quorum Settings
Skipped welcome page
No witness required for DR


SETUP SQL SERVER AVAILABILITY GROUP








Add Replicate SQLB



SETUP BACKUP OPTION




Show DASHBOARD





Automatic seeding was setup - so waited and HEALTHY status arrived later





SETUP Listener



Add .10.87
ADD 20.87









TEST FAILOVER IN DISASTER RECOVERY SETUP


Shutdown SQLA


Working in SQLB - Check Cluster node status in Cluster Manager

After a short time the cluster status on SQLB is down 




Open ADMIN Powershell session


Import-Module FailoverClusters
$node = "sqlb";
Stop-ClusterNode -Name $node
Start-ClusterNode -Name $node -FixQuorum

(Get-ClusterNode $node).NodeWeight = 1
Failed

Start Cluster from Services.msc with /fixquorum option


Enter /fixquorum and hit Start from “Cluster Service” properties


Back  to powershell


(Get-ClusterNode $node).NodeWeight = 1
$nodes = Get-ClusterNode -Cluster $node
$nodes | Format-Table -property NodeName, State, NodeWeight




Fix Quorum




Check NODES


Role is still down

This is expected as we need to update the availability group,
Checked - dashboard



Update the availability group with data loss command as this is async DR setup


ALTER AVAILABILITY GROUP "sqlag" FORCE_FAILOVER_ALLOW_DATA_LOSS




Wait for SQLB to switch to primary - refresh view after a few minutes




Database is now running on SQLB as primary



Start Wizard to failback to SQLA 

As this is a test - starting SQLA server and using standard wizard to move the primary back to SQLA 


Accept Data Loss message
Connect

On SQLB resume data movement

Check Dashboard on SQLA

Fix Quorum via cluster manager





Google +