SAP 대표 BSEG, BSET 테이블은 cluster table이다.
논리적으로 SAP에 생성되기 때문에 SQL Management Studio에는 안보이고 SE11, SE16n에서만 보인다.
Difference between cluster tables and pool tables
만약 이러한 실체가 없는 논리 테이블을 백업하거나 복사해야 하는 경우다.
1. SE11 -> BSEG -> ZBSEG 복사 후 Transparent 테이블 변경
2. SQL Server Management 확인
3. Abap Program을 통해 필요 데이터 BSEG->ZBSEG 복사
이렇게 처리한다.
TOP
TABLES: BSEG, ZBSEG, BSET, ZBSET. * DB Connect Valueable DATA: dbs TYPE dbcon-con_name. * Eternal Tables Data: gt_bseg type table of BSEG with HEADER LINE. Data: gt_bset type table of BSET with HEADER LINE. |
START-OF-SELECTION. PERFORM copydata. PERFORM TRANSFER_DATA. PERFORM SEND_DATA. |
PERFORM copy_bseg. PERFORM copy_bset. FORM COPY_BSEG . clear: gt_bseg. IF p_gjhar ne ''. SELECT * INTO corresponding fields of table gt_BSEG FROM bseg WHERE GJAHR eq p_gjhar. if sy-subrc = 0. write: 'bseg data select ok'. if sy-subrc = 0. write: 'bseg modify ok'. ELSE. write: 'bseg data modify FAIL!!!!!'. endif. ELSE. write: 'bseg data select FAIL!!!!!'. endif. ENDIF. ENDFORM. " COPY_BSEG FORM COPY_BSET . clear: gt_bset. IF p_gjhar2 ne ''. SELECT * INTO corresponding fields of table gt_BSET FROM bset WHERE GJAHR eq p_gjhar2. if sy-subrc = 0. write: 'BSET data select ok'. ELSE. write: 'BSET data select FAIL!!!!!'. endif. ENDIF. ENDFORM. " COPY_BSET |
DB Connection
FORM TRANSFER_DATA . DATA: EXC_REF TYPE REF TO CX_SY_NATIVE_SQL_ERROR, ERROR_TEXT TYPE STRING. DATA : LV_SUBRC . DATA : LV_NATIVE_ERR TYPE STRING, L_MODE(1), L_MESS(70). PERFORM DBCO_CONNECTION CHANGING LV_NATIVE_ERR. ENDFORM. " TRANSFER_DATA FORM DBCO_CONNECTION CHANGING ERROR_TEXT TYPE STRING. DATA : EXC_REF TYPE REF TO CX_SY_NATIVE_SQL_ERROR. DBS = 'KUKSAECHUNG'. TRY. EXEC SQL . CONNECT TO :DBS ENDEXEC. CATCH CX_SY_NATIVE_SQL_ERROR INTO EXC_REF. ERROR_TEXT = EXC_REF->GET_TEXT( ). MESSAGE ERROR_TEXT type 'I'. ENDTRY. ENDFORM. " DBCO_CONNECTION |
FORM SEND_DATA . DATA : LCL_NATIVE_SQL TYPE REF TO CX_SY_NATIVE_SQL_ERROR . DATA : LV_NATIVE_ERR TYPE STRING. PERFORM send_bseg using LV_NATIVE_ERR. PERFORM send_bset using LV_NATIVE_ERR. ENDFORM. " SEND_DATA |
Eternal table에 담긴 BSEG, BSET 데이터를 다른 Database로 이관하는 코드다.
다른 DB로 테이블을 복사하려면 Native SQL을 사용해야 되는데,
Eternal Table을 바로 다른 Database로 넘길 수 없었고, 컬럼 하나하나 지정해야했다.
결국 Loop문을 돌려야 하는데,
60만건 이상 데이터가 넘어가다 보니 30분 이상 돌고 있었다.
뭔가 수정이 필요하다.
FORM SEND_BSEG USING ERROR_TEXT TYPE STRING. DATA : LCL_NATIVE_SQL TYPE REF TO CX_SY_NATIVE_SQL_ERROR . LOOP AT gt_BSEG. TRY. EXEC SQL. insert into dbo.BSEG (MANDT, BUKRS, BELNR, GJAHR, BUZEI, BUZID, AUGDT, AUGCP, AUGBL, BSCHL, KOART, UMSKZ, UMSKS, ZUMSK, SHKZG, GSBER, PARGB, MWSKZ, QSSKZ, DMBTR, WRBTR, KZBTR, PSWBT, PSWSL, TXBHW, TXBFW, MWSTS, WMWST, HWBAS, FWBAS, HWZUZ, FWZUZ, SHZUZ, STEKZ, MWART, TXGRP, KTOSL, QSSHB, KURSR, GBETR, BDIFF, BDIF2, VALUT, ZUONR, SGTXT, ZINKZ, VBUND, BEWAR, ALTKT, VORGN, FDLEV, FDGRP, FDWBT, FDTAG, FKONT, KOKRS, KOSTL, PROJN, AUFNR, VBELN, VBEL2, POSN2, ETEN2, ANLN1, ANLN2, ANBWA, BZDAT, PERNR, XUMSW, XHRES, XKRES, XOPVW, XCPDD, XSKST, XSAUF, XSPRO, XSERG, XFAKT, XUMAN, XANET, XSKRL, XINVE, XPANZ, XAUTO, XNCOP, XZAHL, SAKNR, HKONT, KUNNR, LIFNR, FILKD, XBILK, GVTYP, HZUON, ZFBDT, ZTERM, ZBD1T, ZBD2T, ZBD3T, ZBD1P, ZBD2P, SKFBT, SKNTO, WSKTO, ZLSCH, ZLSPR, ZBFIX, HBKID, BVTYP, NEBTR, MWSK1, DMBT1, WRBT1, MWSK2, DMBT2, WRBT2, MWSK3, DMBT3, WRBT3, REBZG, REBZJ, REBZZ, REBZT, ZOLLT, ZOLLD, LZBKZ, LANDL, DIEKZ, SAMNR, ABPER, VRSKZ, VRSDT, DISBN, DISBJ, DISBZ, WVERW, ANFBN, ANFBJ, ANFBU, ANFAE, BLNBT, BLNKZ, BLNPZ, MSCHL, MANSP, MADAT, MANST, MABER, ESRNR, ESRRE, ESRPZ, KLIBT, QSZNR, QBSHB, QSFBT, NAVHW, NAVFW, MATNR, WERKS, MENGE, MEINS, ERFMG, ERFME, BPMNG, BPRME, EBELN, EBELP, ZEKKN, ELIKZ, VPRSV, PEINH, BWKEY, BWTAR, BUSTW, REWRT, REWWR, BONFB, BUALT, PSALT, NPREI, TBTKZ, SPGRP, SPGRM, SPGRT, SPGRG, SPGRV, SPGRQ, STCEG, EGBLD, EGLLD, RSTGR, RYACQ, RPACQ, RDIFF, RDIF2, PRCTR, XHKOM, VNAME, RECID, EGRUP, VPTNR, VERTT, VERTN, VBEWA, DEPOT, TXJCD, IMKEY, DABRZ, POPTS, FIPOS, KSTRG, NPLNR, AUFPL, APLZL, PROJK, PAOBJNR, PASUBNR, SPGRS, SPGRC, BTYPE, ETYPE, XEGDR, LNRAN, HRKFT, DMBE2, DMBE3, DMB21, DMB22, DMB23, DMB31, DMB32, DMB33, MWST2, MWST3, NAVH2, NAVH3, SKNT2, SKNT3, BDIF3, RDIF3, HWMET, GLUPM, XRAGL, UZAWE, LOKKT, FISTL, GEBER, STBUK, TXBH2, TXBH3, PPRCT, XREF1, XREF2, KBLNR, KBLPOS, STTAX, FKBER, OBZEI, XNEGP, RFZEI, CCBTC, KKBER, EMPFB, XREF3, DTWS1, DTWS2, DTWS3, DTWS4, GRICD, GRIRG, GITYP, XPYPR, KIDNO, ABSBT, IDXSP, LINFV, KONTT, KONTL, TXDAT, AGZEI, PYCUR, PYAMT, BUPLA, SECCO, LSTAR, CESSION_KZ, PRZNR, PPDIFF, PPDIF2, PPDIF3, PENLC1, PENLC2, PENLC3, PENFC, PENDAYS, PENRC, GRANT_NBR, SCTAX, FKBER_LONG, GMVKZ, SRTYPE, INTRENO, MEASURE, AUGGJ, PPA_EX_IND, DOCLN, SEGMENT, PSEGMENT, PFKBER, HKTID, ZZAAMT, ZZPAMT, KSTAR, XLGCLR, PEROP_BEG, PEROP_END, FASTPAY, PRODPER ) values( :gt_BSEG-MANDT, :gt_BSEG-BUKRS, :gt_BSEG-BELNR, :gt_BSEG-GJAHR, :gt_BSEG-BUZEI, :gt_BSEG-BUZID, :gt_BSEG-AUGDT, :gt_BSEG-AUGCP, :gt_BSEG-AUGBL, :gt_BSEG-BSCHL, :gt_BSEG-KOART, :gt_BSEG-UMSKZ, :gt_BSEG-UMSKS, :gt_BSEG-ZUMSK, :gt_BSEG-SHKZG, :gt_BSEG-GSBER, :gt_BSEG-PARGB, :gt_BSEG-MWSKZ, :gt_BSEG-QSSKZ, :gt_BSEG-DMBTR, :gt_BSEG-WRBTR, :gt_BSEG-KZBTR, :gt_BSEG-PSWBT, :gt_BSEG-PSWSL, :gt_BSEG-TXBHW, :gt_BSEG-TXBFW, :gt_BSEG-MWSTS, :gt_BSEG-WMWST, :gt_BSEG-HWBAS, :gt_BSEG-FWBAS, :gt_BSEG-HWZUZ, :gt_BSEG-FWZUZ, :gt_BSEG-SHZUZ, :gt_BSEG-STEKZ, :gt_BSEG-MWART, :gt_BSEG-TXGRP, :gt_BSEG-KTOSL, :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_BSEG-KSTAR, :gt_BSEG-XLGCLR, :gt_BSEG-PEROP_BEG, :gt_BSEG-PEROP_END, :gt_BSEG-FASTPAY, :gt_BSEG-PRODPER ) ENDEXEC. CATCH CX_SY_NATIVE_SQL_ERROR INTO LCL_NATIVE_SQL. ERROR_TEXT = LCL_NATIVE_SQL->GET_TEXT( ). MESSAGE ERROR_TEXT type 'E'. ENDTRY. ENDLOOP. ENDFORM. " SEND_BSEG *&---------------------------------------------------------------------* *& Form SEND_BSET *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_LV_NATIVE_ERR text *----------------------------------------------------------------------* FORM SEND_BSET USING ERROR_TEXT TYPE STRING. DATA : LCL_NATIVE_SQL TYPE REF TO CX_SY_NATIVE_SQL_ERROR . LOOP AT gt_BSET. TRY. EXEC SQL. insert into dbo.BSET (MANDT, BUKRS, BELNR, GJAHR, BUZEI, MWSKZ, HKONT, TXGRP, SHKZG, HWBAS, FWBAS, HWSTE, FWSTE, KTOSL, KNUMH, STCEG, EGBLD, EGLLD, TXJCD, H2STE, H3STE, H2BAS, H3BAS, KSCHL, STMDT, STMTI, MLDDT, KBETR, STBKZ, LSTML, LWSTE, LWBAS, TXDAT, BUPLA, TXJDP, TXJLV, TAXPS, TXMOD) values( :gt_BSET-MANDT, :gt_BSET-BUKRS, :gt_BSET-BELNR, :gt_BSET-GJAHR, :gt_BSET-BUZEI, :gt_BSET-MWSKZ, :gt_BSET-HKONT, :gt_BSET-TXGRP, :gt_BSET-SHKZG, :gt_BSET-HWBAS, :gt_BSET-FWBAS, :gt_BSET-HWSTE, :gt_BSET-FWSTE, :gt_BSET-KTOSL, :gt_BSET-KNUMH, :gt_BSET-STCEG, :gt_BSET-EGBLD, :gt_BSET-EGLLD, :gt_BSET-TXJCD, :gt_BSET-H2STE, :gt_BSET-H3STE, :gt_BSET-H2BAS, :gt_BSET-H3BAS, :gt_BSET-KSCHL, :gt_BSET-STMDT, :gt_BSET-STMTI, :gt_BSET-MLDDT, :gt_BSET-KBETR, :gt_BSET-STBKZ, :gt_BSET-LSTML, :gt_BSET-LWSTE, :gt_BSET-LWBAS, :gt_BSET-TXDAT, :gt_BSET-BUPLA, :gt_BSET-TXJDP, :gt_BSET-TXJLV, :gt_BSET-TAXPS, :gt_BSET-TXMOD ) ENDEXEC. CATCH CX_SY_NATIVE_SQL_ERROR INTO LCL_NATIVE_SQL. ERROR_TEXT = LCL_NATIVE_SQL->GET_TEXT( ). MESSAGE ERROR_TEXT type 'E'. ENDTRY. ENDLOOP. ENDFORM. " SEND_BSET |
'IT > SAP' 카테고리의 다른 글
[SAP/ABAP] Possible Entry, Search Help (0) | 2020.04.23 |
---|---|
[SAP/ABAP] SAP 웹저장소(SMW0)를 이용한 문서연결 펌 (0) | 2020.03.06 |
[SAP/BC] ST02 - Analyzing Buffer and Swaps (0) | 2019.10.30 |
[SAP/SAP] 자주사용하는 tcode (0) | 2019.03.18 |
[SAP/BC] Audit USMM Terminated error (0) | 2019.03.18 |