Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
daniel_esteves2
Explorer
0 Kudos



A
cluster database can store data "variables, structures, tables"
permanently in a table.

For example Indx table in the system that has different
purposes depending on the need for storage of program that you use.

The basic idea is to use the Cluster database so simple.

 





Help
SAP…




For

this class was created YCL_INDX_Z1 , this class will use the table INDX and the Area

'Z1'.

!https://weblogs.sdn.sap.com/weblogs/images/251794841/image002.jpg|height=252|alt=Export|align=middle...!





The ABAP
statements Import, Export and Delete ... database not allow the dynamic
specification of the table or area. For this class can re implement or create a
copy so you can specify other standard or proprietary Cluster.




Class YCL_DRIVE_CLUSTER allows the use of the specific

class for the Cluster. You could create a method of a class that could return

the Cluster class specified for any given business situation.




With this tool you can manage a complex data type

specified by the pdata parameter in the Import and Export methods, if your

program know the complex data type can handle it, not knowing if the data type

method may be invoked and GET_DATA_TYPE create a variable to manage the structure.



<a name="DRIVER" title="DRIVER"></a><a name="_YCL_DRIVER_CLUSTER" title="_YCL_DRIVER_CLUSTER"></a>YCL_DRIVER_CLUSTER

class YCL_DRIVER_CLUSTER definition

  public

  final

  create public .


" public components of class YCL_DRIVER_CLUSTER

" do not include other source files here!!!

public section.



  methods CONSTRUCTOR

    importing

      !NAMECLASS type ANY optional

      !TABLE type ANY optional

      !REGION type ANY optional

    preferred parameter NAMECLASS

    exceptions

      ERROR_CREATE .

  methods DELETE_DATA

    importing

      !PID type ANY .

  methods SET_DATA

    importing

      !PID type ANY

      !PDATA type ANY

      !PWA type ANY optional .

  methods GET_DATA

    importing

      !PID type ANY

    exporting

      !PDATA type ANY

      !PWA type ANY

      !PTYPE type ANY .

  class-methods DET_CLUSTER_TABLE_AREA

    importing

      !TABLE type ANY

      !REGION type ANY

    returning

      value(R) type ref to [YIF_CLDB_0001 | #IF]

    exceptions

      NO_FOUND .

  methods GET_DATA_TYPE

    importing

      !PID type ANY .



private section.



  data M_TYPE type STRING .

  data R_ID type STRING .

  data M_DATA type ref to DATA .

  data MCLUSTER type ref to [YIF_CLDB_0001 | #IF].



  methods DETERM_TYPE

    importing

      !PDATA type ANY .

  methods CLEAR_ALL .

Code Methods

" components of interface YIF_CLDB_0001

interface YIF_CLDB_0001

  public .





  methods R_EXPORT

    importing

      !PID type ANY

      !PDATA type ANY

      !PWA type ANY

      !PINFO type ANY .

  methods R_IMPORT

    importing

      !PID type ANY

    exporting

      !PDATA type ANY

      !PINFO type ANY

      !PWA type ANY .

  methods R_DELETE

    importing

      !PID type ANY .

  methods R_DDIC

    importing

      !PID type ANY

    returning

      value(PINFO) type STRING .

endinterface.



<a name="_YCL_INDX_Z1" title="_YCL_INDX_Z1"></a>YCL_INDX_Z1

class YCL_INDX_Z1 definition

  public

  final

  create public .


" public components of class YCL_INDX_Z1

" do not include other source files here!!!

public section.



  interfaces [YIF_CLDB_0001 | #IF].

Code Methods

METHOD yif_cldb_0001~r_export.

  DATA: st_wa TYPE indx,      "Just Change this by redefining

            sid   TYPE indx-relid."Just Change this by redefining



  MOVE pwa TO st_wa.

  EXPORT str   FROM pinfo

         datos FROM pdata TO   DATABASE

              indx(z1) "Just Change this by redefining

              FROM st_wa

              ID sid.

ENDMETHOD.



METHOD yif_cldb_0001~r_import.

  DATA: st_wa TYPE indx,      "Just Change this by redefining

          sid   TYPE indx-relid."Just Change this by redefining

  IMPORT str   TO pinfo

         datos TO pdata FROM DATABASE

              indx(z1) "Just Change this by redefining

              TO st_wa

              ID sid.

  MOVE st_wa TO pwa.

ENDMETHOD.



METHOD yif_cldb_0001~r_delete.

  DATA sid   TYPE indx-relid. "Just Change this by redefining

  MOVE pid TO sid.

  DELETE FROM DATABASE

               indx(z1)    "Just Change this by redefining

               ID sid.

ENDMETHOD.



METHOD yif_cldb_0001~r_ddic.

  DATA: sid   TYPE indx-relid. "Just Change this by redefining

  EXPORT str  FROM pinfo

      TO DATABASE indx(z1) ID sid."Just Change this by redefining

ENDMETHOD. 



h1. PROGRAM ytest_cluster_01.




PROGRAM ytest_cluster_01.



START-OF-SELECTION.



  TYPES:

    tdd02l TYPE STANDARD TABLE OF dd02l WITH DEFAULT KEY,

     BEGIN OF superstrc,

       str1   TYPE sy,

       table1 TYPE tdd02l,

     END OF superstrc.



  DATA int_wa TYPE indx.



  DATA cluster TYPE REF TO [ycl_driver_cluster | #_YCL_DRIVER_CLUSTER].



  int_wa-loekz = 'X'.

  int_wa-sperr = 'A'.

  int_wa-aedat = sy-datum.

  int_wa-usera = sy-uname.

  int_wa-pgmid = sy-repid.



  CREATE OBJECT cluster

    EXPORTING

      nameclass = 'YCL_INDX_Z1'.



  DATA save TYPE superstrc.



  SELECT * INTO TABLE save-table1 UP TO 100 ROWS FROM dd02l.

  save-str1 = sy.



  BREAK-POINT.

  cluster->set_data( EXPORTING pid   = 'ZTEST'

                               pdata = save

                               pwa   = int_wa ).

  BREAK-POINT.

*************************************************************

  DATA load TYPE superstrc.

  DATA rec_wa TYPE indx.



  cluster->get_data( EXPORTING pid   = 'ZTEST'

                     IMPORTING pdata = load

                               pwa   = rec_wa ).



  BREAK-POINT.



10 Comments