Friday, 4 December 2020

EXCEL MACRO - Multiple excel combine as one excel

1. In Excel - Developer tool at right top - Click Visual basic :

2. Right side - Rightclick on Sheet1 - Insert-Modules. 

3. Paste this code and update the split files folder.


EXCEL MACRO - Multiple excel combine as one excel:

'Description: Combines all files in a folder to a master file.
Sub MergeFiles()
Dim path As String, ThisWB As String, lngFilecounter As Long
Dim wbDest As Workbook, shtDest As Worksheet, ws As Worksheet
Dim Filename As String, Wkb As Workbook
Dim CopyRng As Range, Dest As Range
Dim RowofCopySheet As Integer

RowofCopySheet = 2 ' Row to start on in the sheets you are copying from

ThisWB = ActiveWorkbook.Name

path = "C:\Users\\Desktop\test\newfolder\" ' Dont't forget to change this

Application.EnableEvents = False
Application.ScreenUpdating = False

Set shtDest = ActiveWorkbook.Sheets(1)
Filename = Dir(path & "\*.csv", vbNormal)
If Len(Filename) = 0 Then Exit Sub
Do Until Filename = vbNullString
If Not Filename = ThisWB Then
Set Wkb = Workbooks.Open(Filename:=path & "\" & Filename)
Set CopyRng = Wkb.Sheets(1).Range(Cells(RowofCopySheet, 1), Cells(ActiveSheet.UsedRange.Rows.Count, ActiveSheet.UsedRange.Columns.Count))
Set Dest = shtDest.Range(" A" & shtDest.UsedRange.SpecialCells(xlCellTypeLastCell).Row + 1)
CopyRng.Copy Dest
Wkb.Close False
End If

Filename = Dir()
Loop

Range("A1").Select

Application.EnableEvents = True
Application.ScreenUpdating = True


MsgBox "Done!"
End Sub
-------------------------------------------------------

Press F5 to run the macro to extract the file.





Wednesday, 11 November 2020

substring in Content Modifier in SAP CPI

 substring(//DemandAssignmentRequest/DemandAssignmentRequest/TicketItem/ItemAssignment/AssignmentUUID,6,8)




Monday, 2 November 2020

XPATH or Router namespace based field handling in SAP CPI/SCPI

 In Content Modifier, XPATH namespace based field handling in SAP CPI/SCPI


Input Field: <n1:LX_TKT_EXTERNALID>38683</n1:LX_TKT_EXTERNALID>


If we are using direct namespace like below will not work:

 //DemandReplicationRequest/DemandHeaderInfo/RefTicketInfo/ns1:LX_TKT_EXTERNALID


Correct XPATH: //DemandReplicationRequest/DemandHeaderInfo/RefTicketInfo/*:LX_TKT_EXTERNALID


Field node not exist condition check : (Router)

Router condition: count(//PromisedDateTime) != 0




Count expression in router to field the field/node exist

 In router, we tent to find the node / field exist in the incoming xml , based on the we will route the path.

Expression Type: XML

Condition: count(//PromisedDateTime) = 0 




Monday, 19 October 2020

Property read and calculate length equals zero


Routing logic in CPI:

 ${property.AppTaskID.trim().length()} = '0'




Wednesday, 23 September 2020

Get Bearer token and pull users from SAP cloud platform

When connecting with SCP to pull the users using the API management.

Get the bearer token using the client key and secret and pass that to get the user details.

First call: To get the bearer token


POST: https://api.eu2.hana.ondemand.com/oauth2/apitoken/v1?grant_type=client_credentials


While providing authorization: you have ClientID and Secret from SCP ,so construct in the format below

Basic:  ClientID:ClientSecret – Base64 format(https://www.base64encode.net/)

Authorization : Basic NzJlYjM3NDMtOTQ3OC0zMmI4LTItMDMwM2ZkNmQyNWE0OTVhOGY0LTBlMmMtM2Y0YS05ZTRmLTVkNmY5NzIzMDJjMw== 

Output:

{

"access_token": "42d6da336c437955de45829a611f5b",

"token_type": "Bearer",

"expires_in": 1500,

"scope": "hcp.readAccountMembers hcp.manageAccountMembers hcp.manageAuthorizationSettings hcp.readAuthorizationSettings"

}


Second call: Access token to be passed as Bearer in this call and get the user details from SCP:




GET: https://api.eu1.hana.ondemand.com/authorization/v1/platform/accounts/a79a6ea13/Users



"key":"Authorization","value":"Bearer 42d6da336c437955de45829a611f5b



Output Data:


{

    "Resources": [

        {

            "id": "C5200000",

            "meta": {

                "created": "2020-09-18T13:02:33.628Z",

                "lastModified": "2020-09-18T13:02:33.628Z",

                "location": "https://apissecurity.hana.ondemand.com/authorization/v1/platform/accounts/a79a6ea10/Users/C5200000"

            },

            "schemas": [

                "urn:sap:cloud:scim:schemas:extension:custom:2.0:UserExt",

                "urn:ietf:params:scim:schemas:core:2.0:User"

            ],

            "userName": "C5200000",

            "name": {

                "familyName": "C",

                "givenName": "ramu"

            },

            "emails": [

                {

                    "value": "ramu@gmail.com",

                    "primary": true

                }

            ],

            "roles": [

                {

                    "value": "AccountAdministrator",

                    "primary": false,

                    "type": "Predefined"

                }

            ],

            "urn:sap:cloud:scim:schemas:extension:custom:2.0:UserExt": {

                "userbase": "xxCOM",

                "description": "SAP API Management team"

            }

        }





Tuesday, 22 September 2020

Error: Invalid parametertype used at function 'ge'

When getting an error calling the target system as below:

Error: Invalid parametertype used at function 'ge' 


Date format to be changed from 

((CHANGED_DT ge'2020-08-10T00:00:00') and (CHANGED_DT le'2020-09-22T00:00:00'))


to


((CHANGED_DT ge datetime'2020-08-10T00:00:00') and (CHANGED_DT le datetime'2020-09-22T00:00:00'))


Hope this works!!!