
"-Begin-----------------------------------------------------------------
Function ZREADINCLASSTRING
Importing
Value(I_INCLNAME) Type SOBJ_NAME
Exporting
Value(E_STRINCL) Type String.
"-Variables---------------------------------------------------------
Data:
resTADIR Type TADIR,
tabIncl Type Table Of String,
lineIncl Type String Value '',
strIncl Type String Value ''
.
"-Main--------------------------------------------------------------
Select Single * From TADIR Into resTADIR
Where OBJ_NAME = I_InclName.
Check sy-subrc = 0.
Read Report I_InclName Into tabIncl.
Check sy-subrc = 0.
Loop At tabIncl Into lineIncl.
Concatenate strIncl lineIncl cl_abap_char_utilities=>cr_lf
Into strIncl.
lineIncl = ''.
EndLoop.
E_strIncl = strIncl.
EndFunction.
"-End-------------------------------------------------------------------
//-Begin----------------------------------------------------------------
#include <windows.h>
int main() {
int rc = MessageBox(0, "Hello World from FBSL Dynamic C Layer",
"FBSL Dynamic C Layer", 0);
}
//-End------------------------------------------------------------------
"-Begin-----------------------------------------------------------------
Program ZTESTDYNC2.
"-Constants---------------------------------------------------------
Constants SW_SHOWNORMAL Type i Value 1.
"-Variables---------------------------------------------------------
Data:
oFBSL Type OLE2_OBJECT,
Buffer Type String,
WorkDir Type String,
WinInc Type String,
FileName Type String,
ProcID Type i,
InclCode Type String
.
"-Macros------------------------------------------------------------
Define _.
Concatenate Buffer &1 cl_abap_char_utilities=>cr_lf Into Buffer.
End-Of-Definition.
Define Flush.
Call Function 'AC_SYSTEM_FLUSH' Exceptions Others = 1.
End-Of-Definition.
"-Main--------------------------------------------------------------
Create Object oFBSL 'ScriptX'.
If sy-subrc <> 0 Or oFBSL-Handle = 0 Or oFBSL-Type <> 'OLE2'.
Call Function 'ZSCRIPTXDLL'.
Create Object oFBSL 'ScriptX'.
EndIf.
If sy-subrc = 0 And oFBSL-Handle > 0 And oFBSL-Type = 'OLE2'.
"-Show messages in system debugger, e.g. DebugView--------------
Set Property Of oFBSL 'DebugOutput' = 1.
"-Get SAP GUIs work directory-----------------------------------
Call Method cl_gui_frontend_services=>get_sapgui_workdir
Changing SAPWORKDIR = WorkDir Exceptions Others = 1.
Set Property Of oFBSL 'CurrentDirectory' = WorkDir.
Concatenate '#Include "' WorkDir '\Include\Windows.inc"'
Into WinInc.
Call Method Of oFBSL 'ExtractFbslExe'.
Call Method Of oFBSL 'ExtractFbslWinInc'.
Call Method Of oFBSL 'ExtractFbslCInc'.
"-FBSL script begin-----------------------------------------------------
_ '#AppType GUI'.
_ '#Option Strict'.
_ WinInc.
"-Dynamic C routine begin---------------------------------------------
_ 'DynC Test()'.
"-Read C code from include file-------------------------------------
Call Function 'ZREADINCLASSTRING'
Exporting I_InclName = 'ZTESTDYNCINC'
Importing E_strIncl = InclCode.
_ InclCode.
_ 'End DynC'.
"-Dynamic C routine end-----------------------------------------------
_ 'Sub Main()'.
_ ' Test()'.
_ 'End Sub'.
"-FBSL script end-------------------------------------------------------
Concatenate WorkDir '\TestDynC2.fbs' Into FileName.
Call Method Of oFBSL 'WriteFile' Exporting #1 = FileName
#2 = Buffer.
Flush.
Call Method Of oFBSL 'Shell' = ProcID Exporting
#1 = 'Fbsl.exe' #2 = 'TestDynC2.fbs'
#3 = SW_SHOWNORMAL #4 = 1.
Flush.
Call Method Of oFBSL 'DeleteFileA'
Exporting #1 = 'TestDynC2.fbs'.
Call Method Of oFBSL 'DeleteFileA' Exporting #1 = 'Fbsl.exe'.
Call Method Of oFBSL 'DeleteDirectory'
Exporting #1 = 'CInclude'.
Call Method Of oFBSL 'DeleteDirectory' Exporting #1 = 'Include'.
Free Object oFBSL.
EndIf.
"-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
3 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |