IDOC generation from ABAP program
Hi
I have to object in which I have to Z program which will generate the idoc and pass it to PI system. Can anyone guide me in how to generate IDOC through ABAP custom program. Just need a little guidance in how to create IDOC from an ABAP report.
Any help would be greatly acknowledged.
Thanks!!
Hi I tried to use the program as suggested by Buddhika and Glen, but found error over the statement below:
i_data-sdata = header_segment_data.
Highlighted below in code snap. These two fields are not mutually convertible.
Any suggestions on this.
Similar Messages
-
Sending IDOCS from ABAP Program
hi friends,
can we send IDOC ( of type MATMAS) form ABAP Program. if it possible how can we send, are there any function modules to do so....could any one tell me the procedure to accomplish the task...i have finished the configuration sting in both reciver and sender systems....just need to send material in form of IDOC from abap program.
( Note: not form BD10).
Thanks in advance,
Santosh.Hi,
Follow this code it will help u...
This is for the user created IDOC but as u are making use of ur own basic type i.e., Idoc type MATMAS05
and u can write the code.
*& Report ZZ_Program_To_Create_Idoc
report zz_program_to_create_idoc .
tables: ekko,ekpo.
selection-screen skip 3.
selection-screen begin of block b1 with frame title titl.
selection-screen skip.
select-options s_ebeln for ekko-ebeln.
selection-screen skip.
selection-screen end of block b1.
data: header_segment_name like edidd-segnam value 'Z1EKKO',
item_segment_name like edidd-segnam value 'Z1EKPO',
idoc_name like edidc-idoctp value 'Z19838IDOC1'.
data: header_segment_data like z1ekko,
item_segment_data like z1ekpo.
data: control_record like edidc.
data: messagetyp like edmsg-msgtyp value 'ZZ9838MESG1'.
data: i_communication like edidc occurs 0 with header line,
i_data like edidd occurs 0 with header line.
data: begin of i_ekko occurs 0,
ebeln like ekko-ebeln,
aedat like ekko-aedat,
bukrs like ekko-bukrs,
bsart like ekko-bsart,
lifnr like ekko-lifnr,
end of i_ekko.
data: begin of i_ekpo occurs 0,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
menge like ekpo-menge,
meins like ekpo-meins,
netpr like ekpo-netpr,
end of i_ekpo.
start-of-selection.
select ebeln aedat bukrs bsart lifnr from ekko
into table i_ekko where ebeln in s_ebeln.
select ebelp
matnr
menge
meins
netpr
from ekpo
into table i_ekpo
where ebeln in s_ebeln.
control_record-mestyp = messagetyp.
control_record-rcvprt = 'LS'.
control_record-idoctp = idoc_name.
control_record-rcvprn = '0MART800'.
loop at i_ekko.
header_segment_data-ebeln = i_ekko-ebeln.
header_segment_data-aedat = i_ekko-aedat.
header_segment_data-bukrs = i_ekko-bukrs.
header_segment_data-bsart = i_ekko-bsart.
header_segment_data-lifnr = i_ekko-lifnr.
i_data-segnam = header_segment_name.
i_data-sdata = header_segment_data.
append i_data.
select ebelp
matnr
menge
meins
netpr
from ekpo
into table i_ekpo
where ebeln = i_ekko-ebeln.
loop at i_ekpo.
item_segment_data-ebelp = i_ekpo-ebelp.
item_segment_data-matnr = i_ekpo-matnr.
item_segment_data-menge = i_ekpo-menge.
item_segment_data-meins = i_ekpo-meins.
item_segment_data-netpr = i_ekpo-netpr.
i_data-segnam = item_segment_name.
i_data-sdata = item_segment_data.
append i_data.
endloop.
clear i_ekpo.
refresh i_ekpo.
endloop.
call function 'MASTER_IDOC_DISTRIBUTE'
exporting
master_idoc_control = control_record
OBJ_TYPE = ''
CHNUM = ''
tables
communication_idoc_control = i_communication
master_idoc_data = i_data
exceptions
error_in_idoc_control = 1
error_writing_idoc_status = 2
error_in_idoc_data = 3
sending_logical_system_unknown = 4
others = 5
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
loop at i_communication.
write: 'IDOC GENERATED', i_communication-docnum.
endloop.
commit work.
endif.
initialization.
titl = 'ENTER THE PURCHASE ORDER NUMBER'. -
How to create Inbound Idocs in a ABAP program? Any function Module?
Hello Experts,
My requirement is : I have sales order data which I extracted from third party system in my internal tables. In the same box I need to create inbound Idocs and then consequently create sales orders.
I have used the function module IDOC_INBOUND_WRITE_TO_DB to create inbound Idocs from Sales Orders data in internal tables. I have populated all the data records with correct PSGNUM and HLEVEL values. My plan is to create inbound idocs with this function module and send those to IDOC_INPUT_ORDERS function module which creates Sales Orders.
If a sales order in the internal table in ABAP program contains only one item, then I am getting correct idocs. But if more than one item exists for a sales order then the line item segments which got repeated in Idoc are having PSGNUM and HLEVEL values as zero when I checked in WE02. As a result the hierarchy from the second item segment is getting disturbed and getting the status 60.
I populated T_EDIDD with data records from IDOC_INBOUND_WRITE_TO_DB.
To the function module IDOC_INPUT_ORDERS, T_EDIDC and T_EDIDD are the input. I observed that in T_EDIDD also the PSGNUM and HLEVEL values are blank.
I am getting Status 60 with message 'EDI: Syntax error in IDoc (segment cannot be identified)' for idocs which have more than one item.
I need to extract sales data from third party and create inbound idocs and create sales orders in one ABAP program only. I need to display corresponding Idoc numbers for the corresponding third party sales order number in a listoutput.
Can anybody please provide inputs?
Regards.Hi Anjali,
Thanks for the response.
I have passed the PSGNUM and HLEVEL values while populating the data records. Then I sent the data records and control record information to the function module IDOC_INBOUND_WRITE_TO_DB. Inside this function module there is code to clear the PSGNUM values and HLEVEL values.
for compatibility: clear administration data of data records
perform data_records_wipe
tables
t_data_records.
FORM DATA_RECORDS_WIPE
TABLES
T_DATA_RECORDS_IN STRUCTURE EDIDD.
LOOP AT T_DATA_RECORDS_IN.
CLEAR: T_DATA_RECORDS_IN-MANDT,
T_DATA_RECORDS_IN-DOCNUM,
T_DATA_RECORDS_IN-SEGNUM,
T_DATA_RECORDS_IN-PSGNUM,
T_DATA_RECORDS_IN-HLEVEL.
modify t_data_records_in.
ENDLOOP.
ENDFORM. " DATA_RECORDS_WIPE
This is the code which is clearing all the PSGNUM and HLEVEL values. After coming out of this function module we are getting the error idocs created with disturbed hierarchy.
I need to create INBOUND Idocs with the data in ABAP program.
Please let me know if any inputs? Is there any function module existing to create Inbound Idocs inside an ABAP program?
Regards -
Hi everyone!
Is there a way in ABAP to output XML files? Pls. send code/ function module if any.
From ABAP programs, we are sure that we can output TEXT files, but how about XML files?
The significance of this question is related
Currently we are using XI to interface SAP and AMS, this question for ABAP to produce XML file arose, if for example, the XI server is down and we have to still send data from one system to another. IDocs can also produce XML files, pls confirm. Earlier however, we have preferred XI rather than IDocs to do this. Anyway, any idea regarding this scenario will be greatly appreciated.
Thanks and God bless!
CelesteHi,
Please check this sample codes from other thread.
1. itab --- > xml
xml ---> itab.
2. This program will do both.
(just copy paste in new program)
3.
REPORT abc.
*-------------- DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
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 .
******************************* FIRST PHASE
******************************* FIRST PHASE
******************************* FIRST PHASE
*------------------ Fetch Data
SELECT * FROM t001 INTO TABLE t001.
*------------------- XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = xml_out
* IMPORTING
* LENGTH =
TABLES
FTEXT_TAB = itab.
*-------------- Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:xx.xml'
TABLES
data_tab = itab.
******************************* SECOND PHASE
******************************* SECOND PHASE
******************************* SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
*------------------- XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[]
BREAK-POINT.
Regards,
Ferry Lianto -
Sending IDOC form the ABAP Program
hi friends,
can we send IDOC ( of type MATMAS) form ABAP Program. if it possible how can we send, are there any function modules to do so....could any one tell me the procedure to accomplish the task...i have finished the configuration sting in both reciver and sender systems....just need to send material in form of IDOC from abap program.
( Note: not form BD10).
Thanks in advance,
Santosh.Function MG_IDOC_CREATE_FULL_MAT
( to send the material in full) or
MASTERIDOC_CREATE_REQ_MATMAS (based on idoc reduction)
Just pass
1 ) receiving system: fields rcvprn /
rcvprt. If you leave these 2 fields blank, then it will determine the receiving system(s) via the distribution model.
2 ) marakey = list of material numbers you want to send
3 ) message type.
example :
CALL FUNCTION 'MG_IDOC_CREATE_FULL_MAT'
EXPORTING
rcvpfc = ' '
rcvprn = receiver_prn
rcvprt = receiver_prt
sndpfc = ' '
sndprn = ' '
sndprt = ' '
message_type = mestyp
TABLES
marakey = t_matkeypack
EXCEPTIONS
OTHERS = 0. -
Is it possible to call website from ABAP Program?
Hi Experts,
Is it possible to call website from ABAP Program?
It is very Urgent Help me.
Regards,
Ashok.Hi,
Check the following program:
REPORT ZURL NO STANDARD PAGE HEADING.
DATA: BEGIN OF URL_TABLE OCCURS 10,
L(25),
END OF URL_TABLE.
URL_TABLE-L = 'http://www.lycos.com'.APPEND URL_TABLE.
URL_TABLE-L = 'http://www.hotbot.com'.APPEND URL_TABLE.
URL_TABLE-L = 'http://www.sap.com'.APPEND URL_TABLE.
LOOP AT URL_TABLE.
SKIP. FORMAT INTENSIFIED OFF.
WRITE: / 'Single click on '.
FORMAT HOTSPOT ON.FORMAT INTENSIFIED ON.
WRITE: URL_TABLE. HIDE URL_TABLE.
FORMAT HOTSPOT OFF.FORMAT INTENSIFIED OFF.
WRITE: 'to go to', URL_TABLE.
ENDLOOP.
CLEAR URL_TABLE.
AT LINE-SELECTION.
IF NOT URL_TABLE IS INITIAL.
CALL FUNCTION 'WS_EXECUTE'
EXPORTING
program = 'C:\Program Files\Internet Explorer\IEXPLORE.EXE'
commandline = URL_TABLE
INFORM = ''
EXCEPTIONS
PROG_NOT_FOUND = 1.
IF SY-SUBRC <> 0.
WRITE:/ 'Cannot find program to open Internet'.
ENDIF.
ENDIF.
Regards,
Bhaskar -
Call SXPG _ CALL _ SYSTEM from ABAP program
Hi,
Someone may help me? I need to call the function module SXPG _ CALL _ SYSTEM from ABAP program for to encrypt a file.
I created the command by SM49 , but I don't know how I can call it from ABAP program.
Thanks
Maria CHi Maria.
This is a possible code you can use:
DATA: log LIKE TABLE OF btcxpm WITH HEADER LINE.
Can contain STDOUT, STDERR
commandname =
CALL FUNCTION SXPG_CALL_SYSTEM
IMPORTING
COMMANDNAME = commandname
PARAMETERS = parameters
EXPORTING
STATUS = status
TABLES
EXEC_PROTOCOL = log
EXCEPTIONS
NO_PERMISSION = 1
COMMAND_NOT_FOUND = 2
PARAMETERS_TOO_LONG = 3
SECURITY_RISK = 4
WRONG_CHECK_CALL_INTERFACE = 5
PROGRAM_START_ERROR = 6
PROGRAM_TERMINATION_ERROR = 7
X_ERROR = 8
PARAMETER_EXPECTED = 9
TOO_MANY_PARAMETERS = 10
ILLEGAL_COMMAND = 11
OTHERS = 12.
The following are the comments of the parameters taken from:
http://help.sap.com/saphelp_40b/helpdata/en/fa/0971ee543b11d1898e0000e8322d00/content.htm
Parameters
IMPORTING Parameters
Parameter name
Use
COMMANDNAME
The name of the definition of the external command, as specified in the maintenance function (transaction SM69).
PARAMETERS
Arguments for the external command as specified by the definition in the R/3 System and by the calling program or user.
These arguments are checked for impermissible characters, such as the ; under UNIX. Problems are registered with the SECURITY_RISK exception.
EXPORTING Parameters
Parameter name
Use
STATUS
Returns the final status of the execution of the external command:
· Value O: The external command was started and ran to end successfully.
· Value E: An error occurred; the external command was not run successfully.
Tables Parameters
Parameter name
Use
EXEC_PROTOCOL
Contains the STDOUT and STDERR output of the external command and any output from the target host system.
Exceptions
Exception name
Meaning
X_ERROR
Reserved for future use.
NO_PERMISSION
The AUTHORITY-CHECK of the users authorization for the authorization object S_LOG_COM failed. The user is not authorized to carry out the command named with the specified arguments on the target system.
COMMAND_NOT_FOUND
Command name, as identified by COMMANDNAME and OPERATINGSYSTEM, has not been defined in the maintenance function (transaction SM69).
PARAMETERS_TOO_LONG
The combined argument string (ADDITIONAL_PARAMETERS and the DEFINED_PARAMETERS, as returned in ALL_PARAMETERS) exceeds the limit of 128 characters in length.
SECURITY_RISK
Either:
· The command contains impermissible characters. These are characters with potentially dangerous properties, such as ; under UNIX.
· The command definition specifies that an extra-check function module be run. This function module has rejected execution of the command.
WRONG_CHECK_CALL_
INTERFACE
The command definition specifies that an extra-check function module is to be run. Either this function module is missing, or the interface defined for this function module does not match that of the standard R/3 function module SXPG_DUMMY_COMMAND_CHECK. For more information, please see SXPG_DUMMY_COMMAND_CHECK: Interface for Extra-Check Function Modules.
TOO_MANY_PARAMETERS
The command definition specifies that user-specified arguments for the external command are not allowed. However, an additional string of command arguments was specified.
PARAMETER_EXPECTED
The command definition includes the placeholder character ?, which signifies that additional user-defined arguments are required. However, no additional arguments string was supplied.
PROGRAM_START_ERROR
An error occurred while starting the external command. The R/3 system field SY-MSGV1 contains additional information on the problem.
PROGRAM_TERMINATION_
ERROR
An error occurred while trying to obtain the return code of the external program. The R/3 system field SY-MSGV1 contains additional information on the problem.
ILLEGAL_COMMAND
The external command definition was modified "illegally". That is, the command was not modified by means of the maintenance function (transaction SM69).
The modified command is registered in the system log in its substituted form. The message is registered under the system log ID "LC".
OTHERS
Catch any new exceptions added to this function module.
Hope this will be useful.
Sandro Lombardo -
Call workflow from ABAP program
created a zbusiness object (ZPRODH)with
one key field product hierarchy,
one attribute level number and
one method display.
I tested that zobject and using this object created workflow to display product hierarchy ,it is displaying it. now I have to call it from one abap program.
In the abap program I am calling the funcion module, I
CALL FUNCTION 'SWW_WI_START_SIMPLE'
EXPORTING
TASK = TASK
IMPORTING
WI_ID = WI_ID
TABLES
AGENTS = AGENTS
WI_CONTAINER = WI_CONTAINER.
It is calling the workflow and subrc is 0, but not passing the value to the workflow. Because of that the method is not working, any idea?
Thanks in advancettpa,
Please check this thread:
Re: Workflow from abap program
Also check that your Fm do requires any explicit commit or not?
Hope it will help u
Cheers
Jai -
Call to Java web service from abap program
HI,
I want to call to Java WS from abap program and i read some post how to do that in release of NW 6.4 but I want to know what is the simplest way to do that in release 7.0 .
Many Thanks,
NinaHi Uwe,
Thank you.
I have WSDL or URL how i can call to them ,in the example that you send i don't find the place that it called.
Do i have to create proxy for that ?
BR
Nina -
Execute webdynpro from abap program and return to the caller program
Guys,
I have a question here.
I know there is a way to call an abap webdynpro application from normal abap program by either using a class method, or use a function module WDY_EXECUTE_IN_PLACE by providing
the webdynpro application or using CALL TRANSACTION statement.
But, is there anyways that we can call the webdynpro application from abap program by supplying data to the webdynpro and display to the user from the portal, and then
once the user do some manipulation on the data, can we transfer back the data to the caller abap program?hey ,
you can pack any web-dynpro program in tranasaction code and run it from R/3 and not via portal :
search in " SAPTECHNICAL" how to do so - for some reason i cant post a link here
than you can use call transaction .
regards
ASA -
Procedure to Call Workflow Object from ABAP program in Se38
Hi All,
I have one scenario like i have to call one Workflow object from ABAP program in SE38.The scenario is like below.....
I have to select some records from database table.For example there are 100 records in the internal table.
For all that records i have to invoke Workflow for getting approval from the authorized persons. Once Approval has come to program, It will post one document in SAP and process ends.
Please suggest me how to move forward with this scenario.
Regards
Manas Ranjan PandaHi,
So you want to start a workflow from an ABAP, if an event exists for that particular workflow then the best way is to use fm SAP_WAPI_CREATE_EVENT,
to start a workflow from an ABAP you can use fm SAP_WAPI_START_WORKFLOW.
Kind regards, Rob Dielemans -
To post a mail from ABAP program
dear friends
how to post a mail to SAP inbox of a particular user from ABAP program.get the spool no of the program
we have standard program rstxpdf4 through that convert it to pdf
and through f.m SO_NEW_DOCUMENT_ATT_SEND_API1 u can send mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = x_document_data
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = it_packing_list
CONTENTS_BIN = it_contents_bin
CONTENTS_TXT = it_contents_txt
RECEIVERS = it_receivers
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8 .
IF SY-SUBRC <> 0.
retcode = sy-subrc.
perform protocol_update.
else . -
Sending an email to users from abap program
Hi experts ,
How to send an email to users from abap program ...
i need full coding please..so that i can copy and paste it in my program.
Thank you in advance.
Rajasekhar.PHi Venkat
check the below simple code to convert spool to HTML and email it
data: list type table of abaplist with header line.
data: htmllines type table of w3html with header line.
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
start-of-selection.
Produce a list
do 100 times.
write:/ sy-index, at 30 sy-index, at 50 sy-index.
enddo.
Save the list
call function 'SAVE_LIST'
tables
listobject = list
exceptions
list_index_invalid = 1
others = 2.
Convert the list
call function 'WWW_LIST_TO_HTML'
tables
html = htmllines.
Send mail
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
if sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif. -
Passing data from abap-program to mssql database table thro native sql
Hi,
To pass the data from abap-program to mssql server,i have created database connection through dbco t.code.
now i am trying to get connection thro native sql but am not able to get it .Am working in ECC 5.0.
Could anyone help me on this.Did i miss anything?
i have tried Native-sql like this.
DATA: CON_NAME LIKE DBCON-CON_NAME VALUE 'BIW'.
EXEC SQL.
CONNECT TO :con_name AS 'C1'
ENDEXEC.
Thanks in advance.Hi,
Trying to do the same here, only using Oracle DB.
DATA: dbc TYPE DBCON_NAME VALUE 'BI'
TRY.
EXEC SQL.
CONNECT TO :dbc
ENDEXEC.
IF sy-subrc NE 0.
RAISE EXCEPTION TYPE cx_sy_native_sql_error.
ENDIF.
CATCH cx_sy_native_sql_error INTO oref_native_sql_error.
sql_emsg = oref_native_sql_error->get_text( ).
MESSAGE sql_emsg TYPE 'I'.
ENDTRY.
I keep getting the message 'Native SQL exception has occured' (because of the RAISE statement, I wonder how we can get a meaningfull error description).
Of course this can be a result of a number of network issues, so I'm trying to resolve this together with my BC admin.
I suggest the same to you..
In the meantime, if anyone can help out, it will be appreciated.
Regards,
SD -
SMS from ABAP program to send error message
Hi,
I would like to know what are settings to be done in the system to send an SMS from ABAP program using FM 'SO_DOCUMENT_SEND_API1'.I was trying to send SMS using above FM but the error was "Cannot process message, no route from <userid> to <Mobile.no> ".
Pls let me know the pre requisites to send an SMS using above FM.
Regards,
NivasHi,
I have gone thru this blog but I want send SMS to US Mobile no.I checked other webservice but it supports only few cellular networks in US.
any other alternate for this...
anyway thanks for your reply
Regards,
Nivas
Maybe you are looking for
-
Issue with running Linux on a Windows 7 64 bit (on MC7 mac book pro via Boot Camp)
I'm running Windows 7 64 bit (native via BootCamp) on a new MBP MC7. When I'm trying to run a 64 bit Linux (CentOS) using VM Player, I received following error " CPU doesn't support long mode. Use a 32 bit distribution". Is it because of VT is not en
-
I Have problems with texting and using the keyboard since going on the new update is07 it's like a delayed reaction when I'm typing
-
MSI 280 R9 possible Dead of arrival?
Chief complaint: No video signal from DVI/HDMI from card. After installing catalyst, windows will blue screen at login until MSI R9 280 card is taken out of the PCI slot New build with MSI R9 280, gigabyte GAB85M-D3H mobo (compatible with my card),
-
Hardware requirement for running exchange 2010 on vmware workstation
Dear Team,I need to create a exchange 2010 sp2 on a guest os on vmware workstation.kindly help me out with the physical hardware requirements for a home user
-
I just replaced an old HP 840C with the 6500A, and cannot find a way to do 2 sided printing. After 1 1/2 hours on "live chat", I was told that this model cannot do this. If so, this is totally unbelieveable, and will result in my total black-lintin