cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP MAPPING

Former Member
0 Kudos

Hi all,

I newly started to work with ABAP mapping,for testing purpose i chose a simple structure

Source

EMPDetails->EMP->Ename->EmpNo->Deptno->sal

For testing I chose source and target same

my mapping program

TYPE-POOLS: IXML.

CLASS CL_IXML DEFINITION LOAD.

TYPES: BEGIN OF EMP_HEAD,

EMP TYPE STRING,

END OF EMP_HEAD.

TYPES: BEGIN OF EMP_DTL,

EName TYPE STRING,

EmpNo TYPE STRING,

Hire_Date TYPE STRING,

Address TYPE STRING,

END OF EMP_DTL.

  • DATA: BEGIN OF WA_HDR,

  • HDR TYPE TABLE OF EMP_HEAD,

  • END OF WA_HDR.

  • TYPES: BEGIN OF WA_DTL,

  • DTL TYPE EMP_DTL,

  • END OF WA_DTL.

DATA: O_CONV TYPE REF TO CL_ABAP_CONV_IN_CE,

O_CONV_E TYPE REF TO CL_ABAP_CONV_OUT_CE,

O_ST_ERR TYPE REF TO CX_ST_ERROR,

O_TR_ERR TYPE REF TO CX_TRANSFORMATION_ERROR,

WA_REC TYPE EMP_HEAD,

WA_DTLE TYPE EMP_DTL,

T_HDR TYPE TABLE OF EMP_HEAD,

  • W_HDR LIKE TABLE OF WA_HDR,

W_HDR TYPE EMP_HEAD,

T_DTL TYPE TABLE OF EMP_DTL,

W_DTL TYPE EMP_DTL,

V_NUMBER(6) TYPE N,

V_CNT(2) TYPE N,

V_ERR_MSG TYPE STRING,

V_RFC_ERR(255),

V_AMT TYPE P DECIMALS 2,

V_DEST TYPE RFCDEST,

V_SOURCE TYPE STRING.

  • ** Convert the incoming xstring to string.

CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE

EXPORTING

INPUT = SOURCE

ENCODING = 'UTF-8'

REPLACEMENT = '?'

IGNORE_CERR = ABAP_TRUE

RECEIVING

CONV = O_CONV.

TRY.

CALL METHOD O_CONV->READ

IMPORTING

DATA = V_SOURCE.

CATCH CX_SY_CONVERSION_CODEPAGE.

*-- Should ignore errors in code conversions

CATCH CX_SY_CODEPAGE_CONVERTER_INIT.

*-- Should ignore errors in code conversions

CATCH CX_PARAMETER_INVALID_TYPE.

CATCH CX_PARAMETER_INVALID_RANGE.

ENDTRY.

*

    • Use simple transformation from XML to internal table

TRY .

CALL TRANSFORMATION ('ZF_Test_IN')------->not sure wht needs to be used

SOURCE XML V_SOURCE

RESULT ROOT = WA_REC.

CATCH CX_ST_ERROR INTO O_ST_ERR.

V_ERR_MSG = O_ST_ERR->GET_TEXT( ).

RAISE EXCEPTION TYPE CX_MAPPING_FAULT EXPORTING ERROR_TEXT = V_ERR_MSG.

CATCH CX_TRANSFORMATION_ERROR INTO O_TR_ERR.

V_ERR_MSG = TEXT-001.

RAISE EXCEPTION TYPE CX_MAPPING_FAULT EXPORTING ERROR_TEXT = V_ERR_MSG.

ENDTRY.

LOOP AT T_DTL INTO W_DTL .

  • Memo

  • V_AMT = V_AMT + WA_DTL-ACCT_AMT.

  • WA_ODTL-MEMO-SATZTYP = '1'.

  • WA_ODTL-MEMO-TABNAME = 'FEBSCSB'.

  • WA_ODTL-MEMO-KWBTR_M = WA_DTL-ACCT_AMT.

  • WA_ODTL-MEMO-CHECT = WA_DTL-AGENCY.

  • WA_ODTL-MEMO-AGBUK = WA_DTL-CC_CODE.

  • IF WA_HDR-PYMNT_INDI = '2A' OR

  • WA_HDR-PYMNT_INDI = '2B' OR

    • WA_HDR-PYMNT_INDI = '06'.

  • WA_ODTL-MEMO-XBLNR = WA_DTL-MISC_ACCT_INV_NO.

    • ENDIF. *

    • Clearing

  • CLEAR: WA_OCLR.

  • WA_OCLR-SATZTYP = '2'.

  • WA_OCLR-TABNAME = 'FEBSCSC'.

    • IF WA_HDR-PYMNT_INDI = '01' OR

    • WA_HDR-PYMNT_INDI = '03' OR

    • WA_HDR-PYMNT_INDI = '04' OR

    • WA_HDR-PYMNT_INDI = '07'.

    • WA_OCLR-SELFD = 'BELNR'.

    • ELSE.

    • WA_OCLR-SELFD = 'XBLNR'.

    • ENDIF.

*

  • WA_OCLR-SELVON = WA_DTL-MISC_ACCT_INV_NO.

  • APPEND WA_OCLR TO WA_ODTL-CLR.

*

  • APPEND WA_ODTL TO WA_OUT-DTL.

ENDLOOP.

  • WA_OUT-HDR-ESBTR_M = V_AMT.

  • APPEND WA_OUT TO T_OUT.

  • ENDLOOP.

TRY.

CALL TRANSFORMATION ('ZF_test_OUT') -


>not sure wht needs to be used here

SOURCE ROOT = WA_REC

RESULT XML V_SOURCE.

CATCH CX_ST_ERROR INTO O_ST_ERR.

V_ERR_MSG = O_ST_ERR->GET_TEXT( ).

RAISE EXCEPTION TYPE CX_MAPPING_FAULT EXPORTING ERROR_TEXT = V_ERR_MSG.

CATCH CX_TRANSFORMATION_ERROR INTO O_TR_ERR.

V_ERR_MSG = TEXT-002.

RAISE EXCEPTION TYPE CX_MAPPING_FAULT EXPORTING ERROR_TEXT = V_ERR_MSG.

ENDTRY.

REPLACE 'utf-16' IN V_SOURCE WITH 'utf-8'.

O_CONV_E = CL_ABAP_CONV_OUT_CE=>CREATE( ENCODING = 'UTF-8' ).

O_CONV_E->RESET( ).

CALL METHOD O_CONV_E->WRITE

EXPORTING

DATA = V_SOURCE.

RESULT = O_CONV_E->GET_BUFFER( ).

endmethod.

Error Displayed

Error when determining the receiver: Problem while determining receivers using interface mapping: java.lang.NullPointerException thrown during application mapping com/sap/xi/tf/_MM_ERD_: Problem while determining receivers using interface mapping: java.lang.NullPointerException thrown during application mapping com/sap/xi/tf/_MM_ERD_: java.lang.NullPointerException thrown during application mapping com/sap/xi/tf/_MM_ERD_.

Also,Please let me know how to use the same if source and Target are different and if validations are required.

Thanks,

Srinivas

Accepted Solutions (0)

Answers (1)

Answers (1)

MichalKrawczyk
Active Contributor
0 Kudos

hi,

if you're new start correctly with this example at the bottom of this page:

http://help.sap.com/saphelp_nw04/helpdata/en/ba/e18b1a0fc14f1faf884ae50cece51b/content.htm

I don't know where did you get that call transformation (xstl processor)

info for abap mappings

unless you want to use XSLT on ABAP then choose XSL abap mapping and use XSLT

Regards,

Michal Krawczyk

Former Member
0 Kudos

Hi Michel,

The above code with more complexity is implemented in 1 scenario,I tried the same.

Former Member
0 Kudos

HI,

Can you do an external break point and let me know where exactly the abap mapping is throwing exception.

Basically I think the output of ABAP Mapping is not correct.

regards

Unni

Former Member
0 Kudos

Hi ,

Please find the exception raised." CX_MAPPING_FAULT",this was maintained in catch block.

as I doubted the error is raised when calling the Transformation.

Also Where do i maintain the transformation variables?which needs to be called in the call transformation.

how to resolve this?

Thanks,

Srinivasa

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

but why do you use XSLT in abap mapping?

if you want to use XSLT use XSL ABAP mappings

and not abap mappings

Regards,

Michal Krawczyk