sábado, 18 de octubre de 2014

A helpfull SAP PI transaction listing

SAP XI TCODES

1.SXMB_IFR -> Start Integration Builder
2.SXMB_MONI -> Integration Engine - Monitoring
3.SXI_MONITOR -> XI: Message Monitoring
4.SXI_CACHE -> To Access IS runtime cache
5.sxi_cache -> XI data directory cacheidx1 -> idoc adapter
6.idx2 -> idoc metadata
7.idx5 -> monitocr idoc adapter
8.sm21 -> log di sistema
9.st22 -> dump abap (analisi di eccezioni)
10.smq1 -> messages inbound e outbound queue
11.smq2 -> messages inbound e outbound queue
12.smicm -> J2EE administration
13.st06 -> stato della macchina cpu memory filesystem machine status - cpu, 14.memory and file system.
15.st03 -> workload.
16.scc4 -> visualizza mandanti del sistema
17.we20 -> partner profiles
18.sale - ale settings
19.rz10 - edit system profile
20.sm59 ->mantain rfc destinations
21.bd64 -> mantain distribution model (trasformazioni)
22.SU01 -> users
23.AL08 -> list all logged users(user login logon)
24.SE10 -> Change Request
25.SE09 -> Change Request
26.WE05 -> All idocs
27.WE19 -> IDoc Test Tool
28.WE21 -> port definition
29.SE11 -> Data dictionary
30.SM21 -> log sistema xi
31.se37 -> mantain funcion modules
32.SICF -> http server configuration
33.SMGW -> trace, alzare livello di trace.
34.BD13 ->
35.BD64 -> modelli di distribuzione
36.pfcg -> Roles
37.tabella TSTC -> sap transactions codes
38.tabella TSTCT -> transaction descriptions
39.STMS -> transports management
40.SPAM -> apply ABAP support packages
41.SPAU -> manage objects after apply support packages
42.SE01 -> manage change requests
43.SLDCHECK -> Test SLD Connection
44.SLDAPICUST-> SLD API Customizing
45.SXMB_ADM -> Integration Engine - Administration
46.SXMB_MONI_BPE -> Process Engine - Monitoring

miércoles, 15 de octubre de 2014

Linked and local table record size comparing using sp_MsForEchtable in MSSQL Server valid from version 2000 up to 2008

Comparación de cantidad de registros entre dos tablas una en un servidor remoto y otra local

sp_MsForeachtable 'SELECT ''?'' tabla,COUNT(*) registros, ''L'' origen FROM ? A UNION SELECT  ''?'' tabla,COUNT(*) registros, ''R'' origen  FROM SERVER.DATABASE.? B '

jueves, 9 de octubre de 2014

Extended stored procedure for SQL Server 2000 that implements a REXEC protocol client compiled with Visual C++ in Visual Studio 2003

I have done this long time ago, but may be it can be still usefull to somebody.

The first thing is to implement the REXEC protocol client as a wrapper class to be used in the extended stored procedure.

REXEC protocol client wrapper ...

#include "winsock.h"
#include "stdlib.h"

//Constants
const int CONF_BUFF = 50;
const int RECV_BUFF= 256;
const int RESP_BUFF= 512*1024;
/* 
Class: REXEC 
Descrtiption: REXEC Protocol Wrapper
Author: Bonifacio Castillo
Release Date: Aug 17, 2006
*/
class REXEC
{

//Properties
private:
char Response[RESP_BUFF]; //Command Echo Response
char aa[CONF_BUFF]; //Configuring buffer
char rr[RECV_BUFF]; //Recv buffer
int d; //WSAStartup handler
WSADATA ws; //WSAStartup structure
struct sockaddr_in a; //Socket Address handler
SOCKET s; //Socket object
int retVal; //return Value
public:

int PORT ; //Rexec listening port

//Methods
REXEC(){
PORT = 512;
        memset(Response ,0,RESP_BUFF);
retVal = 1;
}
~REXEC(){
free(Response);
free(aa);
free(rr);
}
//Response for Message
void Message(char *);
//Get Response
char* GetResponse();
//Rexec method
int  Execute(char *srvIP, char *user, char *password, char *command);

};
//Get Response
char* REXEC::GetResponse(){
//this->Response[strlen(this->Response)]='\0';
return this->Response;
}
//Response for Message
void REXEC::Message(char *p)
{
p[strlen(p)] = '\0';
if ((strlen(Response)+strlen(p))<=RESP_BUFF)
strcat(Response,p);
memset(p,0,RECV_BUFF);
}
//Rexec method
int REXEC::Execute(char *srvIP, char *user, char *password, char *command){
try{
      //Configure WSAStartup
d = WSAStartup(MAKEWORD(2,0),&ws);
sprintf(aa," WSASTARTUP = %d",d);
//Configure socket port and Socket Type
s = socket(AF_INET,SOCK_STREAM,0);
sprintf(aa," SOCKET = %d",s);
a.sin_family = AF_INET;
a.sin_port = htons(PORT);
a.sin_addr.s_addr = inet_addr(srvIP);

//Open Socket 
d = connect(s, (struct sockaddr *)&a, sizeof( a));
//Rexec Packet Sent \0user\0password\0command\0
send(s,"\0",1,0);
send(s,user,strlen(user)+1,0);
send(s,password,strlen(password)+1,0);
send(s,command,strlen(command)+1,0);
retVal = 1;
//Response receiving bucle
while (retVal > 0)
{
retVal = recv(s,rr,RECV_BUFF,0);
if (retVal!=0) 
Message(rr);   //Message Or Event Sent
}
if (retVal < 0) //Error Code Checking
return retVal; //Return Error Number

return 0; //Return With No Errors
}
catch(...){
return -1;
}
}

Now the helper functions at Helpers.h

#include <vector>
#include <string>

using namespace std;
//Split String
template< typename StrT >
int split(const char* str, const char* delim, 
     vector<StrT>& results, bool empties = true)
{
  char* pstr = const_cast<char*>(str);
  char* r = NULL;
  r = strstr(pstr, delim);
  int dlen = strlen(delim);
  while( r != NULL )
  {
    char* cp = new char[(r-pstr)+1];
    memcpy(cp, pstr, (r-pstr));
    cp[(r-pstr)] = '\0';
    if( strlen(cp) > 0 || empties )
    {
      StrT s(cp);
      results.push_back(s);
    }
    delete[] cp;
    pstr = r + dlen;
    r = strstr(pstr, delim);
  }
  if( strlen(pstr) > 0 || empties )
  {
    results.push_back(StrT(pstr));
  }
  return results.size();
}


Now here we go with the extended stored procedure body

/* 
Class Library: xp_netprotocols.dll
Descrtiption: Extended Store Procedure Library to Use Net Protocols in Microsoft SQL Server 2000
Author: Bonifacio Castillo
Release Date: Aug 17, 2006
History:
Aug 17, 2006 - REXEC protocol Added as xp_rexec Extended Procedure
*/
#include <stdafx.h>
#include "rexec.h"
#include "helpers.h"

#define XP_NOERROR              0
#define XP_ERROR                1
#define MAXCOLNAME 25
#define MAXNAME 25
#define MAXTEXT 255


#ifdef __cplusplus
extern "C" {
#endif

RETCODE __declspec(dllexport) xp_rexec(SRV_PROC *srvproc);

#ifdef __cplusplus
}
#endif

//Print Errors Function
void SendError (SRV_PROC *pSrvProc, CHAR* pErrorMsg) 
{
srv_sendmsg(pSrvProc, SRV_MSG_ERROR, XP_ERROR, SRV_INFO, 1,
        NULL, 0, (DBUSMALLINT) __LINE__,
        pErrorMsg,
        SRV_NULLTERM);
srv_senddone(pSrvProc, (SRV_DONE_ERROR | SRV_DONE_MORE), 0, 0);
}


//Send a Text Message
void Message(SRV_PROC *pSrvProc, CHAR* pErrorMsg){
srv_sendmsg(pSrvProc, SRV_MSG_ERROR, XP_ERROR, SRV_INFO, 1,
        NULL, 0, (DBUSMALLINT) __LINE__,
        pErrorMsg,
        SRV_NULLTERM);
}



//Send Procedure
RETCODE __declspec(dllexport) xp_rexec(SRV_PROC *srvproc)
{
try{
//check parameters
DBSMALLINT params = srv_rpcparams(srvproc);  
if (params<4){
SendError(srvproc,"Incorrect parameter format!\n usage: xp_rexec 'RemoteServerIP','RemoteUserName','Password','RemoteCommand'[,[0..n]Any Integer Value For QUITE Mode]  ");
return XP_ERROR;
}
//Parameter length validation
if  (
(srv_paramlen(srvproc,1)>MAXNAME)||(srv_paramlen(srvproc,1)<7) ||
(srv_paramlen(srvproc,2)>MAXNAME)||(srv_paramlen(srvproc,2)<1) ||
(srv_paramlen(srvproc,3)>MAXNAME)||(srv_paramlen(srvproc,3)<1) ||
(srv_paramlen(srvproc,4)>MAXTEXT)||(srv_paramlen(srvproc,4)<1)
)
{
SendError(srvproc,"Incorrect Parameter Size!\n [RemoteServerIP{7,25},RemoteUserName{1,25},Password{1,25}] = 25 char max len, [RemoteCommand{1,255}] = 255 char max len");
return XP_ERROR;
}
//

//declaring variables
DBCHAR srv[MAXNAME];
DBCHAR usr[MAXNAME];
DBCHAR pwd[MAXNAME];
DBCHAR cmd[MAXTEXT];
DBSMALLINT response=1;
DBSMALLINT i = 0;
DBCHAR colname[MAXCOLNAME];
DBCHAR spText[MAXTEXT];

//Obtain parameters
 
_snprintf(srv, srv_paramlen(srvproc,1), (DBCHAR*)srv_paramdata(srvproc,1));
_snprintf(usr, srv_paramlen(srvproc,2), (DBCHAR*)srv_paramdata(srvproc,2));
_snprintf(pwd, srv_paramlen(srvproc,3), (DBCHAR*)srv_paramdata(srvproc,3));
_snprintf(cmd, srv_paramlen(srvproc,4), (DBCHAR*)srv_paramdata(srvproc,4));

if (params==5){
try{
response =(int)srv_paramdata(srvproc,5) ;
}catch(...){
response = 1;
}
}
srv[srv_paramlen(srvproc,1)]   = '\0';
usr[srv_paramlen(srvproc,2)]   = '\0';
pwd[srv_paramlen(srvproc,3)]   = '\0';
cmd[srv_paramlen(srvproc,4)]   = '\0';

//Send Command to UNIX
REXEC *rexec=new REXEC();
rexec->Execute(srv,usr,pwd,cmd); 
//Retrieve Response
if (response==1){
_snprintf(colname, MAXCOLNAME, "rexec");
srv_describe(srvproc, 1, colname, SRV_NULLTERM, SRVCHAR,MAXTEXT , SRVCHAR, 0, NULL);
//split the rexec response string into substrings using \n as delimiter
vector<string> cadenas;
split(rexec->GetResponse(), "\n", cadenas);
//Send each string as a record to SQL
for( i=0; i < cadenas.size(); ++i )
{
if (strlen(cadenas[i].c_str())>0){
_snprintf(spText, MAXTEXT, cadenas[i].c_str() );

srv_setcoldata(srvproc, 1, spText);
srv_setcollen(srvproc, 1, static_cast<int>(strlen(spText)));
srv_sendrow(srvproc);
}
}
 
// Now return the number of rows processed
srv_senddone(srvproc, SRV_DONE_MORE | SRV_DONE_COUNT, (DBUSMALLINT)0, (DBINT)i);
}
// Free Memory
free(srv);   
free(usr);
free(pwd);
free(cmd);
free(spText);
delete rexec;
// return with no errors
return XP_NOERROR ;
}
catch (...){
return XP_ERROR;
}
}

The code for  STDAFX.cpp

// stdafx.cpp : source file that includes just the standard includes
// xp_netprotocols.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"


The stdafx.h file


// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once


// Insert your headers here
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers

#include <windows.h>
#include <stdio.h>

//Include ODS headers
#ifdef __cplusplus
extern "C" {
#endif 

#include <Srv.h> // Main header file that includes all other header files

#ifdef __cplusplus
}
#endif 




DLL point of entry

// xp_netprotocols.cpp : Defines the entry point for the dll application.
//

#include "stdafx.h"

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
)
{
    return TRUE;
}



Transacciones Fiori

  /UI2/CACHE Register service for UI2 cache use /UI2/CACHE_DEL Delete cache entries /UI2/CHIP Chip Registration /UI2/CUST Customizing of UI ...