Upload data into SAP through standard program
hi!
why don't we prefer to upload data into sap through standard program like RFBIKR00 to upload for vendor master or other standard programs to upload durectly without using BDC or LSMW and how do we upload data into SAP through BAPI.
pls help me with a sample program.
regards
Amit
It totally depends upon the requierment which fields your want to update in transaction if it works with program then use program else go for bdc .
If there is some any screen enhancement with z fields then program will not solve the problem.
For BAPI you check these links:
http://www.sap-img.com/abap/bapi-step-by-step-guidance.htm
http://sap-img.com/bapi.htm
Edited by: shilpi agarwal on Aug 22, 2008 7:28 AM
Similar Messages
-
How to upload data into SAP BW Info Objects using SAP XI
Hi,
I need to upload master and hierarchy data into SAP BW Info Objects using SAP XI as EAI.
Can anyone suggest me the best solution to do it.
Thanks in Advance,
Volker.Hi! Have you not checked the BW-XI Integration document? It is available on the main page of the SDN section for XI. Almost all the steps for the integration are there...
-
How to batch upload some data into SAP system?
Hi All:
I'm a SAP key user in our company, I want to know how to batch upload master data into SAP system? What t-code we can use for batch input?
Thanks in advance!Hi,
I think at least there are four methods for batch input which you can use in SAP system:
Standard mass change t-code: for example, MM17 for mass change of material master data, you can find the mass change t-code under the relevant function module;
T-code SCAT, you can use to record and generate the simple batch input template, it's easy to use for key user;
T-code LSMW, it's another transaction to generate batch input template, it's often used at the beginning of SAP rollout;
ABAP program, of course, ABAP is a universal tool for everything, you can use ABAP to generate a batch input program to upload data into SAP system as well.
So you had better contact your SAP support department, help you to upload data!
Good luck
Tao -
How to upload data into IT0000 using ABAP-HR program
Hello,
I'm required to upload data into multiple infotypes [IT000, 0001, 0002, etc] using single input text file. Can anyone able to guide me, how to upload data into IT0000 using ABAP program ?
Thanks in advance.
Regards
Prabhakar.
Message was edited by:
Prabhakara MuthyalExample code for HR_MAINTAIN_MASTERDATA to COPY IT0002
DATA: INT_0002_FINAL TYPE STANDARD TABLE OF PA0002 WITH HEADER LINE.
DATA: VALUES LIKE PPROP OCCURS 10 WITH HEADER LINE,
RETURN LIKE BAPIRETURN1,.
LOOP AT INT_0002_FINAL.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-PERNR'.
VALUES-FVAL = INT_0002_FINAL-PERNR.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-BEGDA'.
VALUES-FVAL = INT_0002_FINAL-BEGDA.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-ENDDA'.
VALUES-FVAL = INT_0002_FINAL-ENDDA.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-nachn'.
VALUES-FVAL = INT_0002_FINAL-NACHN.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-gblnd'.
VALUES-FVAL = INT_0002_FINAL-GBLND.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-vorna'.
VALUES-FVAL = INT_0002_FINAL-VORNA.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-rufnm'.
VALUES-FVAL = INT_0002_FINAL-RUFNM.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-name2'.
VALUES-FVAL = INT_0002_FINAL-NAME2.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-inits'.
VALUES-FVAL = INT_0002_FINAL-INITS.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-famst'.
VALUES-FVAL = INT_0002_FINAL-FAMST.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-gbdat'.
VALUES-FVAL = INT_0002_FINAL-GBDAT.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-sprsl'.
VALUES-FVAL = INT_0002_FINAL-SPRSL.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-anzkd'.
VALUES-FVAL = INT_0002_FINAL-ANZKD.
APPEND VALUES.
VALUES-INFTY = '0002'.
VALUES-FNAME = 'P0002-natio'.
VALUES-FVAL = INT_0002_FINAL-NATIO.
APPEND VALUES.
* maintain master data
CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'
EXPORTING
PERNR = INT_0002_FINAL-PERNR
ACTIO = 'COP'
BEGDA = INT_0002_FINAL-BEGDA
* ENDDA = INT_0002_FINAL-ENDDA
SUBTY = SPACE
NO_ENQUEUE = SPACE
DIALOG_MODE = '0'
TCLAS = 'A'
IMPORTING
RETURN1 = RETURN
TABLES
PROPOSED_VALUES = VALUES
* MODIFIED_KEYS =
EXCEPTIONS
OTHERS = 1.
IF RETURN IS INITIAL.
WRITE:/' Done....'.
ELSE.
WRITE:/ RETURN-ID, RETURN-TYPE, RETURN-NUMBER, RETURN-MESSAGE_V1, RETURN-MESSAGE_V2, RETURN-MESSAGE_V3, RETURN-MESSAGE_V4.
ENDIF.
CLEAR VALUES.
REFRESH VALUES.
ENDLOOP. -
To upload a data into SAP Table with the help of RFC function in BODS
Hi,
Please provide me step-by-step solution to upload data into any SAP table with the help of RFC function in Data Services.
I have created RFC function that upload data into SAP table. RFC Function contains one table that has same structure as my database table.
In the data services how can i filled the table of RFC function, i am using this function in query transform of data services but it gives me error.
I am also follow link http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsDataServicesTipsand+Tricks
but it did not help me.
Thanks,
AbhishekHi Abhishek,
Did you import the function module in the SAP datastore first? When you open the SAP datastore, the function should be listed in the 'functions' section. If not, import it. Make sure your function is remote executable.
Once the function is there, you can use it in a transformation. In 'Schema Out' right-click on 'Query' (top level) and choose 'New Function Call'. You can then select a datastore and a function in the datastore. The wizard will show you which output parameters are available. I believe you have to add at least one and can select as many as you like.
After confirming your selection the function and the output parameters appear in Schema Out. You can then right-click on the function and choose 'Modify function call'. A popup will appear where you can specify the input parameters.
I hope this helps.
Jan. -
How to clear PSA data in advance berfore upload data into PSA by process
Could someone tell me how to clear previous PSA data before upload data into PSA through process chain,tks
Hi,
Try
Deleting Requests from the PSA
http://help.sap.com/saphelp_nw04s/helpdata/en/b0/078f3b0e8d4762e10000000a11402f/frameset.htm
Hope this helps.
Thanks,
JituK -
How to upload the data into SAP R/3 System
I have a scenario to upload the flat file data into SAP R/3 System.
I will describe my complete scenario here so that it will be better understanding for you to suggest the solution.
The segments that relevant for the upload of customer master data, namely
HD : Header Segment
PF : Partner Function Segment
OP : Output Segment
TX : Tax Segment
CR : Credit Segment
CT : Customer Text SegmentI think you can achieve this with IDOC creation. If it is so follow the steps below.
Basic Type:
Basic IDoc type defines the structure and format of the business document that is to be exchanged between two systems.
Segments:
Segments form the basic building blocks of an IDoc type and are used to store the actual datta. A segment type is the name of a segment and is independent of the SAP elease. A segment definition is the release-specific name of a segment.
Steps in creating Segments:
T.Code WE31
Enter the name for your segment type and click on the create icon.
Type the Short text.
Enter the variable names and data elements.
Save and Go back.
Go to Edit -> Set Release.
Repeat the steps to create more segments.
IDOC TYPE:
Business data is exchanged with an external system using the IDoc Interface.
IDoc types (Special Structures) An IDoc type is defined through its permitted segments. Segments can be dependent on each other (parent and child segments). The IDoc interface can check for each IDoc whether thhe segments contained are compatible with thhe definitiion of its type. This systax check is activated or deactivated in the Partner Profiles.
Steps in creating IDoc Type:
T.Code WE30 to create IDoc Type.
Enter the Object Name, Select Basic Type and click Create Icon
Select the create new option and enter a description for your basic IDOC type and press enter
Select the IDoc name and click Create icon
The system prompts us to enter a segment type and its attributes
Choose the appropriate values and press enter
The system transfers the name of the segment type to the IDoc editor.
Follow these steps to add more number of segments to Parent or as Parent-child relation.
Save it and go back.
Go to Edit -> Set Release.
Message Type:
Steps in Creating Message Type:
T.Code WE81.
change the details from Display mode to Change mode
After selection, the system will give this message "The table is cross client (See help for further info)". Press enter.
Click New Entries to create new Message Type.
Fill details
Save it and go back.
Assign Message Type to IDoc Type:
T.Code WE82
Change the details from Display mode to change mode.
After selection, the system will give this message "The table is cross client (See help for further info)". Press enter.
Click New Entries to create new Message Type.
Fill details
Save it and go back.
Reward Points if useful. -
Problem in getting data into database with standard direct input program
HI All,
I am having problem which is not updating the records in MM01 or MM02 with standard direct input program. i have data in internal table. from that table i am trying to upload into database by using background job MRP_MATERIAL_MASTER_DATA_LOAD.
when i execute my program it is showing message job is started. then i go into sm37 and seethe job status by executing. there also i am seeing job completed succesfully.
but if i go to mm03 and find the materials are updated or created there i couldn't find the material numbers which are from internal table.
So if ny one help me it wil be great.
Thanks in Advance
Venkat NHi Anil,
Thanks for your answer, but i am facing problem is i have material no and denominator and Actual UOM and nominator field values in the flat file.....
by using RMDATIND direct input program with MRP_MATERIAL_UPLOAD as job name for background job while uploading data into database.
here i am not getting data in to database, but when i execute the job in sm37 it is showing that message job processing successfully completed...this is my status..
if u can help me in this it will be gr8ful..
Thanks,
Venkat N -
Using bapi how to upload the data into sap database?
hi dear all,
im facing problem with bapi ? let me edcuate on bapi ..
i will be waiting for reply.
my e-id :[email protected]
thanks®ards
shiva.Hi
A BAPI is a method of a SAP Business Object. BAPI enables SAP and third party applications to interact and integrate
with each other at the Business Object / Process level.
Check this link to know more about BAPI.
http://www.sapgenie.com/abap/bapi/example.htm
http://sappoint.com/abap/
Batch Data Communication (BDC) is the oldest batch interfacing technique that SAP provided since the early versions of R/3. BDC is not a
typical integration tool, in the sense that, it can be only be used for uploading data into R/3 and so it is not bi-directional.
BDC works on the principle of simulating user input for transactional screen, via an ABAP program. Typically the input comes in the form
of a flat file. The ABAP program reads this file and formats the input data screen by screen into an internal table (BDCDATA). The
transaction is then started using this internal table as the input and executed in the background.
In Call Transaction, the transactions are triggered at the time of processing itself and so the ABAP program must do the error handling.
It can also be used for real-time interfaces and custom error handling & logging features. .
To know more about BDC,
check the link.
http://sappoint.com/abap/
Main differences are...
In case of bdc data transfer takes place from flat file into sap system ie the file existing in sap system to sap sytem
where is bapi's r remotly enabled function modules which are assigned to some business objects n used to transfer the data between different business partners who are using different systems other than sap.
not only that...
when you plan to upgrade your system version then bdc willnot support those upgradations where as bapi's will support.
http://www.sap-img.com/abap/ale-bapi.htm
SAP BAPI
BAPI STEPS
Hope this helps.
ashish -
For uploading master data(ex:customer data) into sap,
hi
for uploading master data(ex:customer data) into sap,
which methods you prefer? call
transaction/session/lsmw/bapi? why?
Thanks
RamaHello,
Check this:
COde:
REPORT zprataptable2
NO STANDARD PAGE HEADING LINE-SIZE 255.
DATA : BEGIN OF itab OCCURS 0,
i1 TYPE i,
lifnr LIKE rf02k-lifnr,
bukrs LIKE rf02k-bukrs,
ekorg LIKE rf02k-ekorg,
ktokk LIKE rf02k-ktokk,
anred LIKE lfa1-anred,
name1 LIKE lfa1-name1,
sortl LIKE lfa1-sortl,
land1 LIKE lfa1-land1,
akont LIKE lfb1-akont,
fdgrv LIKE lfb1-fdgrv,
waers LIKE lfm1-waers,
END OF itab.
DATA : BEGIN OF jtab OCCURS 0,
j1 TYPE i,
banks LIKE lfbk-banks,
bankl LIKE lfbk-bankl,
bankn LIKE lfbk-bankn,
END OF jtab.
DATA : cnt(4) TYPE n.
DATA : fdt(20) TYPE c.
DATA : c TYPE i.
INCLUDE bdcrecx1.
START-OF-SELECTION.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = 'C:\first1.txt'
filetype = 'DAT'
TABLES
data_tab = itab.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = 'C:\second.txt'
filetype = 'DAT'
TABLES
data_tab = jtab.
LOOP AT itab.
PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-KTOKK'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02K-LIFNR'
itab-lifnr.
PERFORM bdc_field USING 'RF02K-BUKRS'
itab-bukrs.
PERFORM bdc_field USING 'RF02K-EKORG'
itab-ekorg.
PERFORM bdc_field USING 'RF02K-KTOKK'
itab-ktokk.
PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-LAND1'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-ANRED'
itab-anred.
PERFORM bdc_field USING 'LFA1-NAME1'
itab-name1.
PERFORM bdc_field USING 'LFA1-SORTL'
itab-sortl.
PERFORM bdc_field USING 'LFA1-LAND1'
itab-land1.
PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKN(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
cnt = 0.
LOOP AT jtab WHERE j1 = itab-i1.
cnt = cnt + 1.
CONCATENATE 'LFBK-BANKS(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-banks.
CONCATENATE 'LFBK-BANKL(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-bankl.
CONCATENATE 'LFBK-BANKN(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-bankn.
IF cnt = 5.
cnt = 0.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKN(02)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
ENDIF.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-FDGRV'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFB1-AKONT'
itab-akont.
PERFORM bdc_field USING 'LFB1-FDGRV'
itab-fdgrv.
PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-ZTERM'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB5-MAHNA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFM1-WAERS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFM1-WAERS'
itab-waers.
PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-LIFNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=YES'.
PERFORM bdc_transaction USING 'XK01'.
ENDLOOP.
PERFORM close_group.
Header file:
1 63190 0001 0001 0001 mr bal188 b in 31000 a1 inr
2 63191 0001 0001 0001 mr bal189 b in 31000 a1 inr
TC file:
1 in sb 11000
1 in sb 12000
1 in sb 13000
1 in sb 14000
1 in sb 15000
1 in sb 16000
1 in sb 17000
1 in sb 18000
1 in sb 19000
1 in sb 20000
1 in sb 21000
1 in sb 22000
2 in sb 21000
2 in sb 22000
Regards,
Vasanth -
How can we upload the Time data into SAP system
Dear all,
ingeneral which method we can use to read the Time data and how can we upload that data into SAP system. Please any one can answer this asap.In the recent project that I have done.. the time data is uploaded from the external time recording machine.. in the form a file...
The other way is through CATS... which in turn will populate the time entries as per hte work schedules... and will explicitly have to populate the deviations to the work scheudle by going through transactions..
Please reward the points if it is helpful...
Regards,
Suvan,
Yash Technologies Pvt Ltd, Hyderabad.
Message was edited by:
Suvan -
Hi experts,
I have to upload legacy data into SAP by using eCATT recording Transaction. For doing this I have completed Test script in tcode SECATT. After this what I have to do.. How can I attach my legacy file.. Can anyone help me. ..Its really urgent
Thanks in advanceHi,
There are a series of weblogs in this area. Check them out, I think there are 8 in a series:
/people/sapna.modi/blog/2006/04/10/ecatt--an-introduction-part-i
cheers
Aveek -
Upload bulk data into sap?
hi all,
let me know is there any methods to upload bulk data into sap and can same data be modified , delete , add. please correct me if i am wrong. what i know is that we can do with lsmw method, as i am new to lsmw method please let me know where to hunt for lsmw documentation.
thanks,
john dias.Hi John-
According to SAP, The Data Transfer Workbench supports the automatic transfer of data into the system. The Workbench is particularly useful for various business objects with large amounts of data. It guarantees that data is transferred efficiently and ensures that data in the system is consistent.
Further, The Legacy System Migration Workbench (LSMW) is a tool recommended by SAP that you can use to transfer data once only or periodically from legacy systems into an R/3 System.
For your purpose you might be helped by the following two links-
'Data Transfer Workbench' - http://help.sap.com/saphelp_47x200/helpdata/en/0d/e211c5543e11d1895d0000e829fbbd/frameset.htm
'Using the LSM Workbench for the Conversion' - http://help.sap.com/saphelp_46c/helpdata/en/0f/4829e3d30911d3a6e30060087832f8/frameset.htm
Hope these links help,
- Vik. -
Hi guys,
How to upload a XML file into sap?
is there any function module?
can anybody give me an example program for converting or uploading XML data into sap.
regards,
vinoth.Hi all,
The XML code and XML file given is running fine for me, but when i am using it, my XML file and code, the tables GV_header and GT_item are filling in the perform but outside perform it's empty. Please find the code and XML file , PLease give the answer its urgent, points will be given for sure.
My function module code is:-
FUNCTION Z_MMI_XML_EXTRACT_COPY.
""Local interface:
*" IMPORTING
*" REFERENCE(DOCTYPE) LIKE DRAW-DOKAR
*" REFERENCE(DOCNUM) LIKE DRAW-DOKNR
*" REFERENCE(DOCVER) LIKE DRAW-DOKVR
*" REFERENCE(DOCPART) LIKE DRAW-DOKTL
*" TABLES
*" T_HEADER STRUCTURE ZFI_HEADER
*" T_ITEMS STRUCTURE ZFI_ITEMS
Load iXML Lib.
type-pools: ixml.
class cl_ixml definition load.
data: G_IXML type ref to if_ixml.
data: STREAMFACTORY type ref to if_ixml_stream_factory.
data: ISTREAM type ref to if_ixml_istream.
data: DOCUMENT type ref to if_ixml_document.
data: PARSER type ref to if_ixml_parser.
You should provide the parameter for file name
*LV_FILE_URL = 'C:input_xml.xml'.
types: begin of XML_LINE,
DATA(256) type x,
end of XML_LINE.
***types: begin of TY_HEADER,
CUST_NAME(20) type c,
CARD_NO(20) type c,
TAX_AMOUNT(10) type c,
TOTAL_AMOUNT(10) type c,
end of TY_HEADER.
***types: begin of TY_ITEM,
ITEM_NO(4) type n,
ITEM_ID(20) type c,
ITEM_TITLE(50) type c,
ITEM_QTY(10) type c,
ITEM_UPRICE(10) type c,
end of TY_ITEM.
*data: GV_HEADER type TY_HEADER.
*data: GV_HEADER like zfi_header occurs 0 with header line.
data : GV_HEADER LIKE ZFI_HEADER.
*data: GT_ITEM type standard table of TY_ITEM with header line.
*data: GT_ITEM type standard table of zfi_items with header line.
data: GT_ITEM type standard table of zfi_items with header line.
data: XML_TABLE type table of XML_LINE,
XML_TABLE_SIZE type i.
data: LV_FILE_URL type rlgrap-filename.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
DATA : BEGIN OF wa_draw OCCURS 0,
dokar LIKE draw-dokar,
doknr LIKE draw-doknr,
dokvr LIKE draw-dokvr,
doktl LIKE draw-doktl,
END OF wa_draw.
DATA : g_documenttype LIKE bapi_doc_aux-doctype,
g_documentnumber LIKE bapi_doc_aux-docnumber,
g_documentpart LIKE bapi_doc_aux-docpart,
g_documentversion LIKE bapi_doc_aux-docversion.
*" Itab required in IMPORTING parameter of BAPI
DATA : t_documentfile LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.
DATA : t_documentstructure LIKE bapi_doc_structure OCCURS 0 WITH HEADER
LINE,
itab required in TABLES parameters of BAPI
t_documentfiles LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,
t_components LIKE bapi_doc_comp OCCURS 0 WITH HEADER LINE,
t_return LIKE bapiret2.
DATA : l_docfile TYPE string.
***FILL THE TYPE OF ATTACHMENT in IMPORTING itab**
t_documentfile-wsapplication = 'XML'.
APPEND t_documentfile.
wa_draw-dokar = DOCTYPE.
wa_draw-doknr = DOCNUM.
wa_draw-doktl = DOCPART.
wa_draw-dokvr = DOCVER.
CALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTVIEW2'
EXPORTING
documenttype = wa_draw-dokar
documentnumber = wa_draw-doknr
documentpart = wa_draw-doktl
documentversion = wa_draw-dokvr
documentfile = t_documentfile "IMPORTING itab of BAPI
getstructure = '1'
getcomponents = 'X'
ORIGINALPATH = ' '
HOSTNAME = ' '
getheader = 'X'
DOCBOMCHANGENUMBER =
DOCBOMVALIDFROM =
DOCBOMREVISIONLEVEL =
IMPORTING
return = t_return
TABLES
documentstructure = t_documentstructure
documentfiles = t_documentfiles "TABLES itab of BAPI
components = t_components
LOOP AT t_documentfiles .
ENDLOOP.
l_docfile = t_documentfiles-docfile.
The next step is creating the main factory for the iXML library:
G_IXML = cl_ixml=>create( ).
Now Create Stream Factory
STREAMFACTORY = G_IXML->create_stream_factory( ).
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
*filename = 'C:DMS_SPA.XML'
filename = l_docfile
filetype = 'BIN'
IMPORTING
FILELENGTH = XML_TABLE_SIZE
TABLES
data_tab = XML_TABLE.
ISTREAM = STREAMFACTORY->create_istream_itable( table = XML_TABLE
size = XML_TABLE_SIZE )
Create XML Document instance
DOCUMENT = G_IXML->create_document( ).
Create parser Object
PARSER = G_IXML->create_parser( stream_factory = STREAMFACTORY
ISTREAM = istream
DOCUMENT = document ).
Parse an XML document into a DOM tree
*parser->parse( ).
Parsing Error Processing
if PARSER->parse( ) ne 0.
if PARSER->num_errors( ) ne 0.
data: PARSEERROR type ref to if_ixml_parse_error,
STR type STRING,
I type i,
COUNT type I,
INDEX type i.
COUNT = PARSER->num_errors( ).
write: COUNT, ' parse errors have occured:'.
INDEX = 0.
while INDEX < COUNT.
PARSEERROR = PARSER->get_error( INDEX = index ).
I = PARSEERROR->get_line( ).
write: 'line: ', i.
I = PARSEERROR->get_column( ).
write: 'column: ', i.
STR = PARSEERROR->get_reason( ).
write: STR.
INDEX = index + 1.
endwhile.
endif.
endif.
Close the stream since it �s not needed anymore
call method ISTREAM->close( ).
clear ISTREAM.
DATA : GV_NODE type ref to if_ixml_node.
DATA : GV_NODETEXT type STRING.
data: GV_FIRST_TIME.
GV_FIRST_TIME = 'X'.
GV_NODE = DOCUMENT.
*GT_ITEM-item_no = 1.
GT_ITEM-itemno_acc = 1.
perform GET_DATA tables GT_ITEM
using GV_NODE
changing GV_HEADER.
Last item is still not added.
append GT_ITEM.
APPEND GV_HEADER.
*T_HEADER[] = gv_header[].
t_items[] = gt_item[].
**write : GV_HEADER-cust_name,
GV_HEADER-card_no,
GV_HEADER-tax_amount,
GV_HEADER-total_amount.
**loop at GT_ITEM.
write /:.
write : GT_ITEM-item_no,
GT_ITEM-item_id,
GT_ITEM-item_title,
GT_ITEM-item_qty,
GT_ITEM-item_uprice.
**endloop.
ENDFUNCTION.
FORM Get_data *
***form get_data tables YT_ITEM structure gt_ITEM
using value(x_node) type ref to if_ixml_node
changing Y_HEADER type TY_HEADER.
form get_data1 tables YT_ITEM structure zfi_items
using value(x_node) type ref to if_ixml_node
changing Y_HEADER type zfi_header.
***form get_data tables YT_ITEM structure GT_ITEM
using value(x_node) type ref to if_ixml_node
changing Y_HEADER type TY_HEADER.
data: INDENT type i.
data: PTEXT type ref to if_ixml_text.
data: STRING type string.
data: TEMP_STRING(100).
case X_NODE->get_type( ).
when if_ixml_node=>co_node_element.
STRING = X_NODE->get_name( ).
GV_NODETEXT = STRING.
when if_ixml_node=>co_node_text.
PTEXT ?= X_NODE->query_interface( IXML_IID_TEXT ).
if PTEXT->ws_only( ) is initial.
STRING = X_NODE->get_value( ).
case GV_NODETEXT.
when 'Customer'.
when 'HEADER'.
clear GV_HEADER.
when 'Name'.
when 'INVOICE_IND'.
move STRING to GV_HEADER-cust_name.
move STRING to GV_HEADER-INVOICE_IND.
when 'CompanyCode'.
move STRING to GV_HEADER-CompanyCode.
when 'OBJ_TYPE'.
move STRING to GV_HEADER-OBJ_TYPE.
when 'username'.
move STRING to GV_HEADER-username.
when 'PO_reference'.
move STRING to GV_HEADER-PO_reference.
when 'Invoice_Date'.
move STRING to GV_HEADER-Invoice_Date.
when 'Posting_Date'.
move STRING to GV_HEADER-Posting_Date.
when 'Amount'.
move STRING to GV_HEADER-Amount.
when 'Currency'.
move STRING to GV_HEADER-Currency.
*APPEND GV_HEADER.
Iteam details
when 'invoice_doc_item'.
move STRING to GT_ITEM-ITEMNO_ACC.
when 'currency'.
move STRING to TEMP_STRING.
move TEMP_STRING to GT_ITEM-CURRENCY.
when 'Quantity'.
move STRING to GT_ITEM-Quantity.
when 'UoM'.
move STRING to GT_ITEM-UoM.
endcase.
endif.
endcase.
if GV_NODETEXT = 'Header'.
clear GV_HEADER.
elseif GV_NODETEXT = 'Item'.
if GV_FIRST_TIME ne 'X'.
append GT_ITEM.
clear : gt_item.
GT_ITEM-ITEMNO_ACC = gt_item-itemno_acc + 1.
endif.
GV_FIRST_TIME = ' '.
endif.
Get the next child
X_NODE = x_node->get_first_child( ).
Recurse
while not X_NODE is initial.
perform GET_DATA tables GT_ITEM
using X_NODE
changing GV_HEADER.
X_NODE = x_node->get_next( ).
endwhile.
endform.
the XML file is:-
Thanx in advance -
Uploading data into a fixed length file
hello experts,
I got a task to upload data into a fixed length positional file from internal table.So please help me.
regards,
sriram.Hi there. What you basically need to do is set up the path and name for the export file, move your records to an output table, and then transfer the data to the file that you have specified. We usually set up our export programs so that the user can choose to download the file locally or onto the application server. So first we define the following fields on the selection screen:
PARAMETERS: p_file(128) LOWER CASE OBLIGATORY. "File
*path name from system standard
PARAMETERS: p_path LIKE rlgrap-filename MODIF ID fpn. "Path Name
PARAMETERS: p_local AS CHECKBOX. "Local File Flag
Then we use this to set the path to the application server:
INITIALIZATION.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
logical_filename = 'Z_AO_HR_UP_LOAD'
parameter_1 = space
IMPORTING
emergency_flag = lw_emergency_flag
file_name = p_path
EXCEPTIONS
file_not_found = 1
OTHERS = 2.
AT SELECTION-SCREEN OUTPUT.
make path name display only
LOOP AT SCREEN.
CHECK screen-group1 = 'FPN'.
screen-input = 0. "Output (Display) only
MODIFY SCREEN.
ENDLOOP.
After your START-OF-SELECTION statement, you need to open the file for output:
IF p_local NE ztc_on.
Get Path/file Name using logical filename.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
logical_filename = 'Z_AO_HR_UP_LOAD'
parameter_1 = p_file
IMPORTING
emergency_flag = lw_emergency_flag
file_name = p_path
EXCEPTIONS
file_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
w_message = 'No Output file - Missing Logical File Z_AO_HR_UP_LOAD'.
WRITE: / w_message.
IF sy-batch = 'X'. "Is this in a job?
NEW-PAGE.
PERFORM end_of_selection.
MESSAGE e000(38) WITH w_message. "This causes the job to cancel
ELSE.
MESSAGE i000(38) WITH w_message.
ENDIF.
w_stop = 'X'.
STOP.
ENDIF.
*Check if output file is already present.
OPEN DATASET p_path FOR INPUT IN TEXT MODE.
IF sy-subrc EQ 0.
CLOSE DATASET p_path.
WRITE: 'Output Data file already present ', p_path.
*Use the following for logging error message
CONCATENATE 'Ouput Data file already present ' p_path INTO
w_message.
IF sy-batch = ztc_on. "Is this in a job?
NEW-PAGE.
PERFORM end_of_selection.
MESSAGE e000(38) WITH w_message. "This causes the job to cancel
ELSE.
MESSAGE i000(38) WITH w_message.
ENDIF.
w_stop = 'X'.
STOP.
ENDIF.
OPEN DATASET p_path FOR OUTPUT IN TEXT MODE.
IF sy-subrc <> 0.
WRITE: 'Unable to open output dataset - ', p_path.
*Use the following for logging error message
CONCATENATE 'Unable to open output dataset - ' p_path INTO
w_message.
IF sy-batch = ztc_on. "Is this in a job?
NEW-PAGE.
PERFORM end_of_selection.
MESSAGE e000(38) WITH w_message. "This causes the job to cancel
ELSE.
MESSAGE i000(38) WITH w_message.
ENDIF.
w_stop = 'X'.
STOP.
ENDIF.
ENDIF.
Next you perform all of the steps to put your data in the internal table. After the end of selection we then transfer the data from the original internal table (which has many separate fields defined) to a second internal table, t_outfile, in which each record has a single field that is the total length of the original itab record:
*Internal table for Output data
DATA : BEGIN OF t_outfile OCCURS 0,
text(1000).
DATA : END OF t_outfile.
Then you can download your file, checking whether it goes to a local drive or the application server:
IF p_local EQ ztc_on.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = p_file
TABLES
data_tab = t_outfile
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
gui_refuse_filetransfer = 8
OTHERS = 9.
ELSE.
LOOP AT t_outfile.
TRANSFER t_outfile TO p_path.
ENDLOOP.
ENDIF.
Now close your dataset if it is on the application server:
IF p_local NE ztc_on.
CLOSE DATASET p_path.
ENDIF.
I hope this helps!
- April King
Maybe you are looking for
-
Things stopped working since I've upgraded to V29
There is something very wrong with FF on my laptop (now V30). I am writing this from my desktop, because one of the problems I'm having is that I can't log in, nor even start a new account from there. The problem started when I updated to the version
-
Hi, I'm having a problem with arial.....it displays as a comic style font. Why is this? I really need to get this sorted ASAP as we have a lot of trade work coming in from other printers, and if they use arial in their artwork it can create some seri
-
Hi, to everyone plz help me how accounting enteries are happening in Invoice Reduction PO: 100 nos @ 10 INR GR: 40 nos Invoice: 40 nos @ 12 INR = 480 INR how enteries takes place. thanks
-
BSP to query Sql database?
Just curious to find out if this is an option.. We web AS 6.40, can we write in ABAP to query data from a SQL database? Thanks in advance.. Vince
-
Dear All, I am trying to configure the follwoing scenario (Available in BI 7.0) in my BW system, which is BW 3.5. I'll be creating 'Z' objects with help of this help link. http://help.sap.com/saphelp_nw2004s/helpdata/en/43/13286e8d5c6f3fe10000000a422