Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP XML Parser

0 Likes
595

Hi,

Can anyone tell me how the SAP XML Parser works in Abap?

And how to use it?

Thanks & Regards,

Jeba.

2 REPLIES 2
Read only

Former Member
0 Likes
479

hi jeba,

Prior to SAP ERP 6.0 Enhancement Package 2 (EhP2), loading data for Central Contractor Registration (CCR) was a two-step process: data was first read from a flat file and preloaded into SAP tables, then a separate program was executed to create or update vendor master records by means of CREMAS05 iDoc. When EhP2 is installed, new CCR programs (FMFGCCR_CREATE and FMFGCCR_UPDATE) can be customized by means of an enhancement implementation to access CCR data in real time – for example, using Point-to-Point or XI interface with the CCR server (see the documentation and sample implementation classes for enhancement spot FMFG_CCR_PROCESS).

New CCR create/update programs available in EhP2 receive and process CCR data which includes creating and updating SAP vendor master records based on the provided mapping of CCR fields into SAP vendor master fields as well as creating/updating records in the SAP CCR tables. Design of the main program RFFMCCRVENDORCREATE01 is independent of the data source and of the method of processing the data. Default method of creating CCR records in SAP is defined by the default implementation of Enhancement Spot FMFG_CCR_VENDOR_MAINTAIN - FMFG_CCR_VENDOR_MAINTAIN_IMPL and is based on the method call to method MAINTAIN of vendor master class interface VMD_EI_API.

The data source as well as mapping from the data source to SAP CCR table fields and SAP vendor master fields is completely customizable and has to be defined in a custom implementation of Enhancement Spot FMFG_CCR_PROCESS.

We deliver two sample implementations for a CCR interface: one is based on SAP Exchange Infrastructure (XI) and one is a Point-to-Point (P2P) interface. You can define other data sources, such as a flat file or an RFC call to another system, yourself.

The XI sample solution includes XI interface with XML based mapping for Request and Response messages to and from the CCR server. The SAP CCR create/update program calls a proxy method, which is automatically generated based on the CCR XML schema used in XI, to request and receive CCR data through the XI middleware. Use of XI allows interfacing with additional systems as part of the CCR interface as well as provides extensive XML parsing, mapping, validation, and error handling features. Setting up XI based interface requires some minimal XI configuration and implementation of the XI based sample BAdI implementation CL_FMFG_CCR_PROCESS_SAMPLE for enhancement spot FMFG_CCR_PROCESS.

The P2P sample solution defines a P2P interface directly between the ERP layer and the CCR server by means of an HTTP communication protocol. This method might be more appealing to the customers who cannot use XI in their SAP landscapes. Here all XML mapping and parsing are defined in the custom implementation of the method GET_DATA.

New CCR Tables

The following new CCR tables were introduced in EhP2

● FMCCRVENDOR_HDR (CCR Vendor Header)

● FMCCRVENDOR_CORP (CCR Vendor Corporate Information)

● FMCCRVENDOR_GS (CCR Vendor Goods and Services)

Table FMCCRTVENDOR is not populated by the new CCR programs.

Please reward if helpful.

Read only

hymavathi_oruganti
Active Contributor
0 Likes
479

Th following is an exmaple to parse an xml.

form parse_xml_document.

data: lo_parse_error type ref to if_ixml_parse_error.

clear: gf_onoff.

*-- Create the main factory

go_ixml = cl_ixml=>create( ).

*-- Create the initial document

go_xmldoc = go_ixml->create_document( ).

*-- Create the stream factory

go_stream_factory = go_ixml->create_stream_factory( ).

*-- Create an input stream for the table

go_istream = go_stream_factory->create_istream_itable(

table = gt_xml_table

size = g_filesize ).

*-- Create the parser

go_xmlparser = go_ixml->create_parser(

stream_factory = go_stream_factory

istream = go_istream

document = go_xmldoc ).

*-- Parse the stream

if go_xmlparser->parse( ) is initial.

go_xmlnode = go_xmldoc.

perform build_xml_tag_fields.

else.

gf_onoff = c_on.

if go_xmlparser->num_errors( ) ne 0.

g_cntmain = go_xmlparser->num_errors( ).

format color col_negative.

write: / g_cntmain, ' parse errors have occurred'.

skip 2.

clear g_cntloop.

while g_cntloop < g_cntmain.

lo_parse_error = go_xmlparser->get_error( index = g_cntloop ).

g_cntsub = lo_parse_error->get_line( ).

write: / 'Line: ', (3) g_cntsub.

g_cntsub = lo_parse_error->get_column( ).

write: 'Column: ', (3) g_cntsub.

g_tmpstr = lo_parse_error->get_reason( ).

write: g_tmpstr no-gap.

g_cntloop = g_cntloop + 1.

endwhile.

endif.

endif.

clear: g_cntmain, g_cntsub.

endform. " parse_xml_document