Websocket binary data transfer
i have been using websockets recently.
In safari the websocket version is draft-hixie-thewebsocketprotocol-76
i am implementing the websocket server using safari 5.1.3 as websocket client.
After the websocket connection successfully done from safari iam sending the message start
the packet in hexadecimal will be :
00 73 74 61 72 74 FF
From server i replied with the same echo packet (in text mode)then the (onmessage receive event) in safari was triggered.
But if i reply with binary mode as stated in the document of draft-hixie-thewebsocketprotocol-76.
i.e 80 05 73 74 61 72 74
here 80 = for binary mode
05 = length of the data
next five bytes data
after sending this packet the (onmessage receive event) in safari did not triggered
Hi,
don't have any immediate advice, how to solve your problem in first place. You will have to do some debugging. Here is a link to start with
http://help.sap.com/saphelp_nw04/helpdata/en/70/717cfb7d226e44ad4960877da612a4/frameset.htm
Regards
Gregor
Ps. We are at the same dilemma, quite comfortable with tomcat and fighting the new beast NW, haha, still some way to go to reach expert status
Similar Messages
-
Last packet not arriving after binary data transfer
Hi folks,
I have written a server app that receives a text header and a binary data block (e.g. an image). To read the text header I use a scanner "in" (to be more comfortable). Then after that I use the "bis" to get the binary data.
That works so far. I get a header and binary block and then I want to send back a header and a binary data block to the client in the same way.
My problem: In most of the cases (not always but mostly reproducable) delivering the result the last packet is not delivered to the client.
These are my streams, readers and writers:
bis = new BufferedInputStream(client.getInputStream());
sr = new InputStreamReader(bis);
in = new Scanner(sr);
bus = new BufferedOutputStream(client.getOutputStream());
response = new PrintWriter(bus);Here is the part of the file transfer back to the client:
int copyBytes = 0;
long copyTotal = 0;
byte[] copyBuf = new byte[client.getSendBufferSize()];
while ((copyBytes = cis.read(copyBuf)) != -1)
bus.write(copyBuf, 0, copyBytes);
copyTotal = copyTotal + copyBytes;
System.out.println(copyBytes + "/" + copyTotal + " / " + fileSize);
if (copyTotal >= fileSize)
break;
bus.flush();
System.out.println("Finished copyStream");
[...]On the client I have basically the same (the other way round - first send a header + binary block and then receive it):
while ((bytesRead = bis.read(buffer)) != -1)
fileStream.write(buffer, 0, bytesRead);
bytesTotal = bytesTotal + bytesRead;
System.out.println(bytesRead + "/" + bytesTotal + " / " + resultLength);
if (bytesTotal >= resultLength)
break;
System.out.println("here i am");The output on the server is something like:
Start copyStream
46966/46966 / 46966
Finished copyStreamOn the client it is like
38950/38950 / 46966It never comes to the point where it should say "here i am" although on the server it writes that everything has been transferred.
I found out that when I do a bus.close() at the server afterwards at the server then the last package arrives. But then I cannot continue using this connection, but I want to keep the connection waiting for additional header + binary block (or waiting for a "quit").
I tested this on Windows and Linux (for the case there could be an OS specific strange behavior).
What am I doing wrong? Wherever I search I don't find really different approaches to receive and send data. The only difference I can see from other samples is that I do use a reader and just when expecting binary data I use the underlying byte oriented stream. After flushing I go back reading from the "higher level" reader.
The strange thing is that receiving the text header and binary block on the server works fine but when sending response back to the client it does not work.
What I already tried:
I tried nulling my readers while reading from the underlying byte oriented stream for the case they get confused with the binary data and if data is read from the underlying byte oriented stream (did that on server and client side). That did not help.
I tried - as already mentioned - closing the bus stream - which closed my connection which I don't want but delivered the last package.
I also tried using different type of binary stream. I used a TIF image, JPG image and finally tried also with a text content (treated as binary data) and only with the last text content the problem did not occur. But this should not make a difference when reading the byte stream.
I am struggling now for two days with this problem and my last idea is trying to remove the readers in general and using just the binary oriented streams (which is more work for identifying the header lines which are plain text - anyway). But I have the doubt that this will not help because I already tried dropping them when transferring the binary block.
Another link that I found is [http://rox-xmlrpc.sourceforge.net/niotut/index.html|http://rox-xmlrpc.sourceforge.net/niotut/index.html] - is it possible that I have to use nio for this? - But why can I then see plenty of examples without the use of nio what sense would it then make having the "normal" sockets without nio?jtahlborn wrote:
yes, you generally cannot mix Readers and InputStreams. you mentioned that you were reading "byte by byte". but you weren't. you were reading "char by char" (with some more buffering). as mentioned by a previous poster, put a DataInputStream on top of your BufferedInputStream and use that exclusively.Thanks, that was the reason - now it works! Thanks a very lot!
I have seen many samples and documentation where streams where taken to an upper level with readers with and without buffering. But I was not aware that I then have to use always exclusively the object on the upmost level. Reviewing some samples I can see that there is indeed no mixed usage. -
Using custom document protocal in B2B for Binary data transfer
Hello All,
Below are the steps that I am performaing in my project
1) I am enquing the message using B2b adapter to JMS queue on SOA server
2) I have selected opaque and binary fomat while configuring the JMS adapter
3) Before invoking b2b adapter to push the message, trying to set below proeprties in bpel
<bpelx:toProperty name="b2b.fromTradingPartnerId"
variable="varFromParty"/>
<bpelx:toProperty name="b2b.toTradingPartnerId" variable="varToParty"/>
<bpelx:toProperty name="b2b.documentTypeName"
variable="varDocTypeName"/>
<bpelx:toProperty name="b2b.documentProtocolVersion"
variable="varDocTypeRevision"/>
<bpelx:toProperty name="b2b.documentProtocolName"
variable="varEventName"/>
<bpelx:toProperty name="b2b.documentDefinitionName"
variable="varDocDefName"/>
<bpelx:toProperty name="jca.jms.JMSMessageID" variable="varMsgId"/>
<bpelx:toProperty name="jca.jms.JMSProperty.FROM_PARTY"
variable="varFromParty"/>
<bpelx:toProperty name="jca.jms.JMSProperty.TO_PARTY"
variable="varToParty"/>
<bpelx:toProperty name="jca.jms.JMSProperty.DOCTYPE_NAME"
variable="varDocTypeName"/>
<bpelx:toProperty name="jca.jms.JMSProperty.DOCTYPE_REVISION"
variable="varDocTypeRevision"/>
<bpelx:toProperty name="jca.jms.JMSProperty.MESSAGE_TYPE"
variable="varMsgType"/>
<bpelx:toProperty name="jca.jms.JMSProperty.DOCPROT_NAME"
variable="varEventName"/>
on B2b console
1) I have configured JMS listenign channel, file deliver channels properly
2) I have defined docuemnt definition under custom document protocal without xsd
custom->1.0->Binary->Binary_def
3) created agrement and selected file as deleivery channel
when testing this case
- bpel- B2b adapter successfully pushing message into jms queue on soa server
- b2b jms listening channel is able to pickup the message from jms-queue but encountering with the document protocal definition error
- if I check reports section - sender and reciever are showing as same partner name where as in wired message all the properties(to_party, from_party etc..) are getting populated with the values that we sent from bpel
I am not able to figure out the issue so please let us know what extra parameteres that I need to send from bpel to come out of this issue. PLease treat this as imp since i have deliverable.
Thanks,
AnjanaHi Anuj,
Thanks for the quick response. This option fixed the issue. thanks for your suggestion.
I tried this option earlier when I was doing some R&D, at that time message iteself was not picked up by B2b listening channel from jms queue so I have unchecked and didn't try this option again.
Regards,
Anjana -
How can I transfer binary data from a database to another database?
Hi all.
I want to transfer binary data from a MS SQL Server 2000 to anohter SQL Server 2000.
I created JDBC(table) to JDBC(stored procedure) scenario,and
I uploaded a JPG image file to the sender table using the java program I developed.
The JPG data was transfered to receiver,but the transfered data was broken.
I can't not open the file correctly.
Can XI transfer binary data using JDBC adapter?
The sender table structure is following.
<b>column (data type)</b>
id (int 4)
binary (binary 8000)
flag (int 4)
The receiver stored procedure parameter is following.
<b>parameter (data type)</b>
id (smallint)
binary (binary 8000)
flag (smallint)
Regards.
YuukiHi,
<i>Can XI transfer binary data using JDBC adapter?</i>
Ans: Yes
Supported JDBC Types
http://help.sap.com/saphelp_nw04s/helpdata/en/16/9dc9ac8bc72a48b80e639abaa2e497/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
Mapping JDBC types to Java types
http://help.sap.com/saphelp_nw04/helpdata/en/7d/79dfa72d1049bc963f4f272bb1638e/frameset.htm
Regards,
Prateek -
The problem of using webservice to transfer binary data
I want to use webservice to realize downloading file , and then I think we can to transform the whole file to binary data ,and then use webservice to deliver these datas to client. but there is a promble. When the file size is a bit large , such as exceeding 1.5M , then client will receive error report. How to solve this promble. Another I think when server transforming the whole file to binary data , It should apply for much memory , as large as the file. I think this is not a good solution . Any one can give me some ideas ? How to realize download file using webservice(the server is oc4j)
839507 wrote:
the picture does not synchronize with sound. Why? Where is the problem??Dear Automotive Mechanic,
My car won't start, where is the problem?
Sincerly,
Captain Foss -
Data transfer from sap r/3 into excel sheet for mi01
hi gurus,
as i am a xi consultant i got requirement to write a program for data transfer from sap r/3 into excel sheet for MI01.can any body help me by giving sample code or example for this requirement.please help me.Hi Rohit,
This is an upload program and it has used both function modules to upload from an excel to R3 and to download from R3 onto excel.
GUI_UPLOAD
GUI_DOWNLOAD
are the function modules used.
Hope this helps,
*Output: Downloads error records onto presentation server,
* Displays report with number of success and error records
REPORT ZMCG047CONTR NO STANDARD PAGE HEADING
LINE-SIZE 255
MESSAGE-ID ZM.
*& Table declarations
TABLES : T001W, "Plants/Branches
T024E, "Purchasing Organizations
T001. "Company Codes
* TYPE-POOLS DECLARATION
TYPE-POOLS : SLIS.
* Types Declaration *
TYPES: BEGIN OF T_RECORD, "record storing contract info
LIFNR(010), "Vendor Number
EVART(004), "Agreement Type
EKORG(004), "Purchasing Organization
EKGRP(003), "Purchasing Group
WERKS(004), "Plant
LGORT(004), "Storage Location
KDATB(010), "Valid start Date
KDATE(010), "Valid End Date
ZTERM(004), "Payment Terms
KTWRT(020), "Target Value
EPSTP(001), "Item Category
EMATN(018), "Material Number
KTMNG(017), "Target Quantity
NETPR(014), "Net Price
PEINH(006), "Net Price Unit
BPRME(003), "Net Price Order Price Unit
IDNLF(035), "Vendor Material number
WEBRE(001), "GR Based-IV
MEPRF(001), "Pricing Date Category
LTEX1(040), "Info Text
DATAB(010), "Valid From
DATBI(010), "Valid To
KSCHL(004), "Condition Type
KBETR(016), "Condition Rate if scale is not given
KONWA(005), "Currency
KPEIN(005), "Condition Pricing Unit
KMEIN(003), "Condition Unit of Measure
KSTBM(019), "Scale
KBETR_01(016), "Scale Rate
DEL_FLAG, "Delete Flag Indicator
ERR_MSG(100), "Error Message
END OF T_RECORD,
BEGIN OF T_ERR_RECORD, "to have error records stored
LIFNR(010), "Vendor Number
EVART(004), "Agreement Type
EKORG(004), "Purchasing Organization
EKGRP(003), "Purchasing Group
WERKS(004), "Plant
LGORT(004), "Storage Location
KDATB(010), "Valid start Date
KDATE(010), "Valid End Date
ZTERM(004), "Payment Terms
KTWRT(020), "Target Value
EPSTP(001), "Item Category
EMATN(018), "Material Number
KTMNG(017), "Target Quantity
NETPR(014), "Net Price
PEINH(006), "Net Price Unit
BPRME(003), "Net Price Order Price Unit
IDNLF(035), "Vendor Material number
WEBRE(001), "GR Based-IV
MEPRF(001), "Pricing Date Category
LTEX1(040), "Info Text
DATAB(010), "Valid From
DATBI(010), "Valid To
KSCHL(004), "Condition Type
KBETR(016), "Condition Rate if scale is not given
KONWA(005), "Currency
KPEIN(005), "Condition Pricing Unit
KMEIN(003), "Condition Unit of Measure
KSTBM(019), "Scale
KBETR_01(016), "Scale Rate
DEL_FLAG, "Delete Flag Indicator
ERR_MSG(100), "Error Message
END OF T_ERR_RECORD,
BEGIN OF T_LOEKZ, "To have deletion indicators for materials
LOEKZ(001), "Deletion indicator in purchasing document
EMATN(018), "Material Number
WERKS(004), "Plant
LGORT(004), "Storage Location
BSTYP(001), "Purchasing document category
END OF T_LOEKZ,
BEGIN OF T_MATNR, " Type definition to store details of materials
MATNR(018), "Material Number
END OF T_MATNR,
BEGIN OF T_T001, " Type definition for company codes
BUKRS(004), " Company Code
END OF T_T001,
BEGIN OF T_ZMVXREF, "Cross-Reference table type
D_ALTKN(10), "Legacy Vendor Number
D_BUKRS(4), "Legacy Company Code
M_ALTKN(10), "SAP Company Code
END OF T_ZMVXREF,
BEGIN OF T_LFA1, "Master data of vendors
LIFNR(10), "Vendor Number
END OF T_LFA1,
* Type Declaration for T024E (Company Codes)
BEGIN OF T_T024E,
EKORG LIKE T024E-EKORG, "Purchasing organization
BUKRS LIKE T024E-BUKRS, "Company Code
END OF T_T024E,
* Type Declaration for t001w (Plant)
BEGIN OF T_T001W,
WERKS LIKE T001W-WERKS, "Plant
END OF T_T001W,
* Type Declatation for String Line
BEGIN OF T_STR1, "#EC NEEDED
SLINE(6000) TYPE C,
END OF T_STR1.
TYPES: BEGIN OF T_BDCDATA. "BDC Data
INCLUDE STRUCTURE BDCDATA.
TYPES: END OF T_BDCDATA.
* Internal Tables Declaration *
DATA:
* Internal table to store input file data
I_RECORD TYPE STANDARD TABLE OF T_RECORD INITIAL SIZE 0,
* Internal table to capture errors
I_ERR_REC TYPE STANDARD TABLE OF T_ERR_RECORD INITIAL SIZE 0,
* Internal table to check for deletion indicators
I_LOEKZ TYPE STANDARD TABLE OF T_LOEKZ INITIAL SIZE 0,
* Internal table to check for material numbers
I_MATNR TYPE STANDARD TABLE OF T_MATNR INITIAL SIZE 0,
* Internal table used for storing Cross-Reference data of Vendor
I_ZMVXREF TYPE STANDARD TABLE OF T_ZMVXREF INITIAL SIZE 0,
* Internal table for holding Vendor Numbers from Master table
I_LFA1 TYPE STANDARD TABLE OF T_LFA1 INITIAL SIZE 0,
* Internal table for holding Purchase Org and Company Codes
I_T024E TYPE STANDARD TABLE OF T_T024E INITIAL SIZE 0,
* Internal table for holding Plants
I_T001W TYPE STANDARD TABLE OF T_T001W INITIAL SIZE 0,
* Internal table for storing a list of Company Codes
I_T001 TYPE STANDARD TABLE OF T_T001 INITIAL SIZE 0,
* Internal table used for ALV Reporting
I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
* Internal table used for holding List Header
I_LISTHEADER TYPE SLIS_T_LISTHEADER, "EC NEEDED
* Internal table to hold ALV Event
I_ALV_EVENT TYPE SLIS_T_EVENT,
* Internal table to hold Sort Info for ALV Report
I_SORT TYPE SLIS_T_SORTINFO_ALV,
* Internal table for BDC Data
I_BDCDATA TYPE STANDARD TABLE OF T_BDCDATA INITIAL SIZE 0,
* Internal table for messages
I_MESSTAB TYPE TABLE OF BDCMSGCOLL,
* Internal table for String line
I_STR1 TYPE STANDARD TABLE OF T_STR1 INITIAL SIZE 0.
* Work Area Declaration *
DATA:
* Work Area to hold data for the Open Contract
WA_RECORD TYPE T_RECORD,
* Work Area to hold previous record data
WA_RECORDPREV TYPE T_RECORD,
* Work Area to hold errors
WA_ERR_REC TYPE T_ERR_RECORD,
* Work Area to hold the Deletion Indicator of materials
WA_LOEKZ TYPE T_LOEKZ,
* Work Area to hold Material numbers of required materials
WA_MATNR TYPE T_MATNR, "EC NEEDED
* Work Area to hold errors occured while performing BDC
WA_MESSTAB TYPE BDCMSGCOLL,
* Work Area to hold field catalog for ALV Reports
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
* Work Area to hold list header data for ALV reports
WA_LISTHEADER TYPE SLIS_LISTHEADER,
* Work Area to hold ALV Event
WA_ALV_EVENT LIKE LINE OF I_ALV_EVENT, "EC NEEDED
* Work Area to hold Layout of ALV Report
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
* Work Area to hold Cross-Reference data of Vendor
WA_ZMVXREF TYPE T_ZMVXREF,
* Work Area to hold Vendor Numbers from Master table
WA_LFA1 TYPE T_LFA1, "EC NEEDED
* Work Area to hold Purchase Org and Company Codes
WA_T024E TYPE T_T024E,
* Work Area to hold Company Codes
WA_T001 TYPE T_T001,
* Work Area to hold Plants
WA_T001W TYPE T_T001W,
* Work Area to hold Sort Info for ALV Report
WA_SORT TYPE SLIS_SORTINFO_ALV,
* Work Area to hold BDC Data
WA_BDCDATA TYPE T_BDCDATA,
* Work Area for String line
WA_STR1 TYPE T_STR1.
* Variables Declaration *
DATA: V_ERRMSG(500), "To temporarily store the error message
V_CONV_DATE(10) TYPE C, "To capture the converted date format
V_DATE LIKE SY-DATUM,
V_REPID LIKE SY-REPID, "holds report id
V_CROSS_REFERENCE_ERROR TYPE I, " cross-reference error
V_INPUTERROR_FLAG VALUE '', " input error status
V_FILENAME TYPE STRING, " File Name
VEN_FLAG(1), " at new status
MAT_FLAG(1), " at new status
V_IND(2) TYPE N, " index of table control
V_IND2(2) TYPE N, " index of table control
V_IND3(2) TYPE N, " index of table control
V_EVRTP1(20),
V_EPSTP1(20),
V_EMATN1(20),
V_KTMNG1(20),
V_NETPR1(20),
V_PEINH1(20),
V_BPRME1(20),
V_TCSELFLAG1(20),
V_KSCHL2(20),
V_KBETR2(20),
V_KONWA2(20),
V_KPEIN2(20),
V_KMEIN2(20),
V_SELKZ2(20),
V_KBETR3(20),
V_KSTBM3(20),
V_LINE TYPE I,
V_STR TYPE X VALUE '09',
V_EXIST TYPE C,
V_EXIST1 TYPE C,
V_ISDIR TYPE C,
V_ISDIR1 TYPE C.
* Constants Declaration *
CONSTANTS: C_TCODE(5) VALUE 'ME31K', "Trx code - Open Contract Creation
C_TRUE VALUE 'X', " Del_Flag indicator
C_LOEKZ_MARKED VALUE 'X', "Deletion indicator for material
C_INPUTERROR_FLAG_YES VALUE 'X', "Input File Indicator
C_VEN_ERR1 VALUE 1, "Error Indicator
C_16(2) VALUE '16',
C_VEN_ERR2 VALUE 2, "Error Indicator
C_VEN_ERR3 VALUE 3, "Error Indicator
C_VEN_SUCS VALUE 0, "Success Indicator
C_SUCCESS LIKE SY-SUBRC VALUE '0',
C_STRUE VALUE 'S', "Del_flag for SAP Errors
C_YTRUE VALUE 'Y', "Del_flag for Success Records
C_MSGTYP_E VALUE 'E', "holds error message type
C_MSGTYP_S VALUE 'S', "holds success message type
C_BSTYP VALUE 'K', "Purchasing Document type is Contract
C_BACKGROUND VALUE 'N', "Background mode
C_FOREGROUND VALUE 'A', "All Screen mode
C_ERRORS VALUE 'E', "Error screen mode
C_WK(2) VALUE 'WK'. "Value Contract
* Selection Screen *
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-033.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS:
* Plant
S_WERKS FOR T001W-WERKS OBLIGATORY,
* Purchase Organization
S_EKORG FOR T024E-EKORG OBLIGATORY.
* Company Code
PARAMETER P_BUKRS LIKE T001-BUKRS OBLIGATORY.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 3.
PARAMETER RB_SERVE RADIOBUTTON GROUP RBX DEFAULT 'X' USER-COMMAND U1.
SELECTION-SCREEN COMMENT 6(19) TEXT-036.
SELECTION-SCREEN POSITION 37.
PARAMETER RB_LOCAL RADIOBUTTON GROUP RBX.
SELECTION-SCREEN COMMENT 40(13) TEXT-035.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
PARAMETERS:
* Parameter holding Input File name
P_FILE LIKE RLGRAP-FILENAME
OBLIGATORY
LOWER CASE
DEFAULT 'C:\'
MODIF ID G1,
P_FILE1 LIKE RLGRAP-FILENAME
OBLIGATORY
LOWER CASE
DEFAULT '/celestica/interface/corp/in/work/'
MODIF ID G2,
* Parameter specifying Mode of calling the Transaction.
P_MODE DEFAULT 'N' OBLIGATORY,
* Check box used to test the input file.
P_TEST AS CHECKBOX DEFAULT 'X',
* Parameter holding Filename for holding Input File Errors
P_IPERR LIKE RLGRAP-FILENAME
OBLIGATORY
LOWER CASE
DEFAULT 'C:\'
MODIF ID G1,
P_IPERR1 LIKE RLGRAP-FILENAME
OBLIGATORY
LOWER CASE
DEFAULT '/celestica/interface/corp/in/work/047_Err.txt'
MODIF ID G2.
SELECTION-SCREEN END OF BLOCK B2.
* AT Selection Screen Events *
* Loop the screen to activate relative paths
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF RB_SERVE = C_TRUE AND SCREEN-GROUP1 = 'G1'.
SCREEN-OUTPUT = 0.
SCREEN-ACTIVE = 0.
SCREEN-INPUT = 0.
ELSEIF RB_LOCAL = C_TRUE AND SCREEN-GROUP1 = 'G2'.
SCREEN-OUTPUT = 0.
SCREEN-ACTIVE = 0.
SCREEN-INPUT = 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
AT SELECTION-SCREEN ON BLOCK B2.
* Checking Access Authorization for the user
CALL FUNCTION 'ZU_DATA_ACCESS_AUTH_CHECK'
EXPORTING
ACTVT = C_16
P_BUKRS = P_BUKRS
TABLES
S_WERKS = S_WERKS
S_EKORG = S_EKORG
EXCEPTIONS
BUKRS_FAILED = 1
VKORG_FAILED = 2
VTWEG_FAILED = 3
EKORG_FAILED = 4
WERKS_FAILED = 5
LGNUM_FAILED = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
AT SELECTION-SCREEN ON P_BUKRS.
IF NOT P_BUKRS IS INITIAL.
SELECT SINGLE BUKRS INTO T001
FROM T001
WHERE BUKRS EQ P_BUKRS.
IF SY-SUBRC NE 0.
MESSAGE I000 WITH TEXT-089.
STOP.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
* Search Help to select Input File path.
PERFORM GET_FILE_NAME USING P_FILE.
* Check for the existence of the file.
IF RB_LOCAL EQ C_TRUE.
CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'
EXPORTING
FNAME = P_FILE
IMPORTING
EXIST = V_EXIST
ISDIR = V_ISDIR
EXCEPTIONS
FILEINFO_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF V_ISDIR IS INITIAL.
IF V_EXIST IS INITIAL.
MESSAGE I000 WITH TEXT-018.
STOP.
ENDIF.
ELSEIF V_ISDIR EQ C_TRUE.
MESSAGE I000 WITH TEXT-068.
STOP.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_IPERR.
* Search Help to select Input Error File path.
PERFORM GET_FILE_NAME USING P_IPERR.
AT SELECTION-SCREEN.
* Validate Transaction Mode
IF P_MODE <> C_BACKGROUND AND
P_MODE <> C_FOREGROUND AND
P_MODE <> C_ERRORS.
MESSAGE I000 WITH TEXT-034.
STOP.
ENDIF.
START-OF-SELECTION.
* Get the Input File Data
V_FILENAME = P_FILE.
PERFORM UPLOAD_FLATFILE_DATA TABLES I_RECORD
USING V_FILENAME.
* Sorting the data by all fields
SORT I_RECORD.
* Ensuring the padding of the empty spaces before the vendor No
CLEAR WA_RECORD.
LOOP AT I_RECORD INTO WA_RECORD.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_RECORD-LIFNR
IMPORTING
OUTPUT = WA_RECORD-LIFNR.
MODIFY I_RECORD FROM WA_RECORD
INDEX SY-TABIX
TRANSPORTING LIFNR.
CLEAR WA_RECORD.
ENDLOOP.
* Input file validation
PERFORM VALIDATE_FLATFILE_DATA.
IF P_TEST = C_TRUE.
IF I_ERR_REC[] IS INITIAL.
MESSAGE I000 WITH TEXT-032.
STOP.
ELSE.
* Display all the error records at the input level.
PERFORM DISPLAY_INPERR_RECORDS.
* Download Error File
PERFORM DOWNLOAD_ERROR_FILE.
ENDIF.
ELSE.
* Build BDC Data
PERFORM BUILD_BDC_DATA.
* Download Error File
PERFORM DOWNLOAD_ERROR_FILE.
* Display the status report.
PERFORM DISPLAY_PROCESSED_RECORDS.
ENDIF.
END-OF-SELECTION.
REFRESH: I_RECORD,
I_ERR_REC,
I_LOEKZ,
I_MATNR,
I_ZMVXREF,
I_LFA1,
I_T024E,
I_FIELDCAT,
I_LISTHEADER,
I_ALV_EVENT,
I_SORT,
I_BDCDATA,
I_MESSTAB,
I_STR1.
FREE: I_RECORD,
I_ERR_REC,
I_LOEKZ,
I_MATNR,
I_ZMVXREF,
I_LFA1,
I_T024E,
I_FIELDCAT,
I_LISTHEADER,
I_ALV_EVENT,
I_SORT,
I_BDCDATA,
I_MESSTAB,
I_STR1.
*& Form GET_file_name
* Fetches the file and path from the presentation system
* --> p1 Path along with the file name
FORM GET_FILE_NAME USING L_FILE LIKE RLGRAP-FILENAME.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
MASK = ',*.TXT,*.txt.'
MODE = 'O'
TITLE = TEXT-011
IMPORTING
FILENAME = L_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
CASE SY-SUBRC.
WHEN 1.
MESSAGE I000 WITH TEXT-084.
STOP.
WHEN 2.
MESSAGE I000 WITH TEXT-085.
STOP.
WHEN 3.
MESSAGE I000 WITH TEXT-086.
STOP.
WHEN 4.
MESSAGE I000 WITH TEXT-087.
STOP.
ENDCASE.
ENDFORM. " GET_file_name
*& Form upload_flatfile_data
* Uploading data from Flat File
FORM UPLOAD_FLATFILE_DATA
TABLES I_L_RECORD STRUCTURE WA_RECORD
USING L_FILENAME TYPE STRING.
DATA WA_L_RECORD TYPE T_RECORD.
* Upload the Flat file data
IF RB_LOCAL EQ C_TRUE. "File is on the Local System
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_FILENAME
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = I_L_RECORD
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
CASE SY-SUBRC.
WHEN 0.
DESCRIBE TABLE I_L_RECORD LINES V_LINE.
IF V_LINE EQ 0.
MESSAGE I000 WITH TEXT-065.
STOP.
ENDIF.
WHEN 1.
MESSAGE I000 WITH TEXT-068.
STOP.
WHEN 2.
MESSAGE I000 WITH TEXT-069.
STOP.
WHEN 3.
MESSAGE I000 WITH TEXT-070.
STOP.
WHEN 4.
MESSAGE I000 WITH TEXT-071.
STOP.
WHEN 5.
MESSAGE I000 WITH TEXT-072.
STOP.
WHEN 6.
MESSAGE I000 WITH TEXT-073.
STOP.
WHEN 7.
MESSAGE I000 WITH TEXT-074.
STOP.
WHEN 8.
MESSAGE I000 WITH TEXT-075.
STOP.
WHEN 9.
MESSAGE I000 WITH TEXT-076.
STOP.
WHEN 10.
MESSAGE I000 WITH TEXT-077.
STOP.
WHEN 11.
MESSAGE I000 WITH TEXT-078.
STOP.
WHEN 12.
MESSAGE I000 WITH TEXT-079.
STOP.
WHEN 13.
MESSAGE I000 WITH TEXT-080.
STOP.
WHEN 14.
MESSAGE I000 WITH TEXT-081.
STOP.
WHEN 15.
MESSAGE I000 WITH TEXT-082.
STOP.
WHEN 16.
MESSAGE I000 WITH TEXT-083.
STOP.
ENDCASE.
CLEAR V_LINE.
ELSEIF RB_SERVE EQ C_TRUE. "File is on the Application Server
P_MODE = C_BACKGROUND.
OPEN DATASET P_FILE1 FOR INPUT IN TEXT MODE.
CHECK SY-SUBRC EQ C_SUCCESS.
CLEAR WA_STR1.
DO.
READ DATASET P_FILE1 INTO WA_STR1.
IF SY-SUBRC <> 0. " NE SUCCESS.
EXIT.
ELSEIF SY-SUBRC EQ C_SUCCESS.
APPEND WA_STR1 TO I_STR1.
CLEAR WA_STR1.
ENDIF. " ENDIF on SY-SUBRC 0 Check.
ENDDO. " ENDDO
DELETE I_STR1 WHERE SLINE EQ ' '.
DESCRIBE TABLE I_STR1 LINES V_LINE.
IF V_LINE EQ 0.
MESSAGE S000 WITH TEXT-065.
STOP.
ENDIF.
LOOP AT I_STR1 INTO WA_STR1.
CLEAR: WA_L_RECORD.
SPLIT WA_STR1-SLINE AT V_STR
INTO WA_L_RECORD-LIFNR
WA_L_RECORD-EVART
WA_L_RECORD-EKORG
WA_L_RECORD-EKGRP
WA_L_RECORD-WERKS
WA_L_RECORD-LGORT
WA_L_RECORD-KDATB
WA_L_RECORD-KDATE
WA_L_RECORD-ZTERM
WA_L_RECORD-KTWRT
WA_L_RECORD-EPSTP
WA_L_RECORD-EMATN
WA_L_RECORD-KTMNG
WA_L_RECORD-NETPR
WA_L_RECORD-PEINH
WA_L_RECORD-BPRME
WA_L_RECORD-IDNLF
WA_L_RECORD-WEBRE
WA_L_RECORD-MEPRF
WA_L_RECORD-LTEX1
WA_L_RECORD-DATAB
WA_L_RECORD-DATBI
WA_L_RECORD-KSCHL
WA_L_RECORD-KBETR
WA_L_RECORD-KONWA
WA_L_RECORD-KPEIN
WA_L_RECORD-KMEIN
WA_L_RECORD-KSTBM
WA_L_RECORD-KBETR_01
WA_L_RECORD-DEL_FLAG
WA_L_RECORD-ERR_MSG.
APPEND WA_L_RECORD TO I_L_RECORD.
CLEAR: WA_L_RECORD,
WA_STR1.
ENDLOOP.
REFRESH I_STR1.
CLOSE DATASET P_FILE1.
ENDIF.
ENDFORM.
*& Form BDC_DYNPRO
* Data populated into i_bdcdata table for program
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = C_TRUE.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM.
*& Form BDC_FIELD
* Data populated into i_bdcdata table for fields
FORM BDC_FIELD USING FNAM FVAL.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM.
*& Form convert_date
* Converting the data from the file format to mm/dd/yyyy format
* <--P_wa_record_kdatb Source Date
* <--p_l_conv_date Target Date
FORM CONVERT_DATE USING L_DATE
L_TAR_DATE.
CONCATENATE L_DATE+0(2)
L_DATE+3(2)
L_DATE+6(4)
INTO L_TAR_DATE.
ENDFORM. " convert_date
*& Form validate_flatfile_data
* Validating the input file
FORM VALIDATE_FLATFILE_DATA.
DATA: L_TODAY LIKE SY-DATUM,
L_STARTDATE_C LIKE SY-DATUM,
L_ENDDATE_C LIKE SY-DATUM,
L_ENDDATE_C1 LIKE SY-DATUM,
L_STARTDATE_C1 LIKE SY-DATUM,
L_STARTDATE(8),
L_ENDDATE(8).
* Fetch indicator for all records on the material, plant & storage
* location combination.
IF NOT I_RECORD[] IS INITIAL.
REFRESH I_LOEKZ.
SELECT EMATN " Material Number
WERKS " Plant
LGORT " Storage Location
BSTYP " Purchasing Document Category
LOEKZ " Deletion indicator
INTO TABLE I_LOEKZ
FROM EKPO
FOR ALL ENTRIES IN I_RECORD
WHERE EMATN = I_RECORD-EMATN
AND WERKS = I_RECORD-WERKS
AND LGORT = I_RECORD-LGORT
AND BSTYP = C_BSTYP
AND LOEKZ = C_LOEKZ_MARKED.
IF SY-SUBRC EQ 0.
SORT I_LOEKZ BY EMATN WERKS LGORT BSTYP LOEKZ.
ENDIF.
* Fetching Plants for all entries in the selection screen
REFRESH I_T001W.
SELECT WERKS "Plant
INTO TABLE I_T001W
FROM T001W
WHERE WERKS IN S_WERKS.
IF SY-SUBRC EQ 0.
SORT I_T001W BY WERKS.
ENDIF.
* Fetching materials for the plants listed in flat file
REFRESH I_MATNR.
SELECT MATNR " Material Number
INTO TABLE I_MATNR
FROM MARC
FOR ALL ENTRIES IN I_RECORD
WHERE WERKS = I_RECORD-WERKS.
IF SY-SUBRC EQ 0.
SORT I_MATNR BY MATNR.
ENDIF.
* Fetching Company Codes for repective Purchase Organizations
REFRESH I_T024E.
SELECT EKORG " Purchase Organization
BUKRS " Company Code
INTO TABLE I_T024E
FROM T024E
WHERE EKORG IN S_EKORG.
IF SY-SUBRC EQ 0.
SORT I_T024E BY EKORG.
ENDIF.
* Fetching SAP Data using Legacy Data.
REFRESH I_ZMVXREF.
SELECT D_ALTKN
D_BUKRS
M_ALTKN
INTO TABLE I_ZMVXREF
FROM ZMVXREF
FOR ALL ENTRIES IN I_RECORD
WHERE D_ALTKN = I_RECORD-LIFNR.
IF SY-SUBRC EQ 0.
SORT I_ZMVXREF BY D_ALTKN D_BUKRS.
ENDIF.
* Fetching Vendors from LFA1
IF NOT I_ZMVXREF[] IS INITIAL.
REFRESH I_LFA1.
SELECT LIFNR
INTO TABLE I_LFA1
FROM LFA1
FOR ALL ENTRIES IN I_ZMVXREF
WHERE LIFNR = I_ZMVXREF-M_ALTKN.
IF SY-SUBRC EQ 0.
SORT I_LFA1 BY LIFNR.
ENDIF.
ENDIF.
* Start Validating the flat file
CLEAR: WA_RECORD,
WA_T024E,
WA_ZMVXREF,
WA_LFA1,
WA_LOEKZ,
WA_MATNR.
LOOP AT I_RECORD INTO WA_RECORD.
L_TODAY = SY-DATUM.
L_STARTDATE = WA_RECORD-KDATB.
L_ENDDATE = WA_RECORD-KDATE.
IF WA_RECORD-DEL_FLAG IS INITIAL.
READ TABLE I_T001W INTO WA_T001W
WITH KEY WERKS = WA_RECORD-WERKS
BINARY SEARCH.
IF SY-SUBRC EQ 0.
* Cross-Reference check performed for the given Vendors
READ TABLE I_T024E INTO WA_T024E
WITH KEY EKORG = WA_RECORD-EKORG
BINARY SEARCH.
IF SY-SUBRC NE 0.
V_CROSS_REFERENCE_ERROR = C_VEN_ERR3.
ELSE.
READ TABLE I_ZMVXREF INTO WA_ZMVXREF
WITH KEY D_ALTKN = WA_RECORD-LIFNR
D_BUKRS = P_BUKRS
BINARY SEARCH.
IF SY-SUBRC EQ 0.
READ TABLE I_LFA1 INTO WA_LFA1
WITH KEY LIFNR = WA_ZMVXREF-M_ALTKN
BINARY SEARCH.
IF SY-SUBRC EQ 0.
V_CROSS_REFERENCE_ERROR = C_VEN_SUCS.
ELSE.
V_CROSS_REFERENCE_ERROR = C_VEN_ERR2.
ENDIF.
ELSE.
V_CROSS_REFERENCE_ERROR = C_VEN_ERR1.
ENDIF.
ENDIF.
* Legacy Vendor could not be mapped
IF V_CROSS_REFERENCE_ERROR EQ C_VEN_ERR1.
V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES. "Inp.file err. occurd
WA_RECORD-DEL_FLAG = C_TRUE.
WA_RECORD-ERR_MSG = TEXT-007.
MODIFY I_RECORD FROM WA_RECORD
TRANSPORTING DEL_FLAG
ERR_MSG
WHERE LIFNR = WA_RECORD-LIFNR.
* Legacy Vendor is mapped but the obtained SAP vendor doesn't exist.
ELSEIF V_CROSS_REFERENCE_ERROR EQ C_VEN_ERR2.
* Inp.file err. occurd
V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
WA_RECORD-DEL_FLAG = C_TRUE.
WA_RECORD-ERR_MSG = TEXT-008.
MODIFY I_RECORD FROM WA_RECORD
TRANSPORTING DEL_FLAG
ERR_MSG
WHERE LIFNR = WA_RECORD-LIFNR.
* Purchase Organization doesn't exist in T024E.
ELSEIF V_CROSS_REFERENCE_ERROR EQ C_VEN_ERR3.
* Inp.file err. occurd
V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
WA_RECORD-DEL_FLAG = C_TRUE.
WA_RECORD-ERR_MSG = TEXT-014.
MODIFY I_RECORD FROM WA_RECORD
TRANSPORTING DEL_FLAG
ERR_MSG
WHERE EKORG = WA_RECORD-EKORG.
* Vendor is mapped and validated successfully
ELSEIF V_CROSS_REFERENCE_ERROR EQ C_VEN_SUCS.
* Checking for the deletion indicator for that record
CONCATENATE WA_RECORD-KDATB+6(4)
WA_RECORD-KDATB+3(2)
WA_RECORD-KDATB+0(2)
INTO
L_STARTDATE.
MOVE L_STARTDATE TO L_STARTDATE_C.
CONCATENATE WA_RECORD-KDATB+6(4)
WA_RECORD-KDATB+0(2)
WA_RECORD-KDATB+3(2)
INTO
L_STARTDATE_C1.
CONCATENATE WA_RECORD-KDATE+6(4)
WA_RECORD-KDATE+3(2)
WA_RECORD-KDATE+0(2)
INTO
L_ENDDATE.
MOVE L_ENDDATE TO L_ENDDATE_C.
CONCATENATE WA_RECORD-KDATE+6(4)
WA_RECORD-KDATE+0(2)
WA_RECORD-KDATE+3(2)
INTO
L_ENDDATE_C1.
READ TABLE I_LOEKZ INTO WA_LOEKZ WITH KEY
EMATN = WA_RECORD-EMATN
WERKS = WA_RECORD-WERKS
LGORT = WA_RECORD-LGORT
BINARY SEARCH.
IF SY-SUBRC EQ 0.
* Inpfle err.occured
V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
WA_RECORD-ERR_MSG = TEXT-003.
WA_RECORD-DEL_FLAG = C_TRUE. "marking the record
MODIFY I_RECORD FROM WA_RECORD
TRANSPORTING DEL_FLAG
ERR_MSG
WHERE LIFNR = WA_RECORD-LIFNR
AND EVART = WA_RECORD-EVART
AND EKORG = WA_RECORD-EKORG
AND EKGRP = WA_RECORD-EKGRP
AND WERKS = WA_RECORD-WERKS
AND LGORT = WA_RECORD-LGORT
AND KDATB = WA_RECORD-KDATB
AND KDATE = WA_RECORD-KDATE
AND ZTERM = WA_RECORD-ZTERM
AND KTWRT = WA_RECORD-KTWRT
AND EPSTP = WA_RECORD-EPSTP
AND EMATN = WA_RECORD-EMATN.
* Validating the Purchasing Organization for Blank/Null
ELSEIF WA_RECORD-EKORG IS INITIAL.
* Inpfle err.occured
V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
WA_RECORD-ERR_MSG = TEXT-010.
WA_RECORD-DEL_FLAG = C_TRUE.
MODIFY I_RECORD FROM WA_RECORD
TRANSPORTING DEL_FLAG
ERR_MSG
WHERE LIFNR = WA_RECORD-LIFNR
AND EVART = WA_RECORD-EVART
AND EKORG = WA_RECORD-EKORG
AND EKGRP = WA_RECORD-EKGRP
AND WERKS = WA_RECORD-WERKS
AND LGORT = WA_RECORD-LGORT
AND KDATB = WA_RECORD-KDATB
AND KDATE = WA_RECORD-KDATE
AND ZTERM = WA_RECORD-ZTERM
AND KTWRT = WA_RECORD-KTWRT
AND EPSTP = WA_RECORD-EPSTP
AND EMATN = WA_RECORD-EMATN.
* Validating the Plant for Blank/Null
ELSEIF WA_RECORD-WERKS IS INITIAL.
* Inpfle err.occured
V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
WA_RECORD-ERR_MSG = TEXT-039.
WA_RECORD-DEL_FLAG = C_TRUE.
MODIFY I_RECORD FROM WA_RECORD
TRANSPORTING DEL_FLAG
ERR_MSG
WHERE LIFNR = WA_RECORD-LIFNR
AND EVART = WA_RECORD-EVART
AND EKORG = WA_RECORD-EKORG
AND EKGRP = WA_RECORD-EKGRP
AND WERKS = WA_RECORD-WERKS
AND LGORT = WA_RECORD-LGORT
AND KDATB = WA_RECORD-KDATB
AND KDATE = WA_RECORD-KDATE
AND ZTERM = WA_RECORD-ZTERM
AND KTWRT = WA_RECORD-KTWRT
AND EPSTP = WA_RECORD-EPSTP
AND EMATN = WA_RECORD-EMATN.
* Validating the Contract Validity Start Date
ELSEIF L_STARTDATE_C1 GT L_TODAY. "#EC PORTABLE
* Inpfle err.occured
V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
WA_RECORD-ERR_MSG = TEXT-004.
WA_RECORD-DEL_FLAG = C_TRUE. "marking the record
MODIFY I_RECORD FROM WA_RECORD
TRANSPORTING DEL_FLAG
ERR_MSG
WHERE LIFNR = WA_RECORD-LIFNR
AND EVART = WA_RECORD-EVART
AND EKORG = WA_RECORD-EKORG
AND EKGRP = WA_RECORD-EKGRP
AND WERKS = WA_RECORD-WERKS
AND LGORT = WA_RECORD-LGORT
AND KDATB = WA_RECORD-KDATB.
* Validating the Contract Validity End Date
ELSEIF L_ENDDATE_C1 LE L_TODAY. "#EC PORTABLE
* Inpfle err.ocrd
V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
WA_RECORD-ERR_MSG = TEXT-005.
WA_RECORD-DEL_FLAG = C_TRUE. "marking the record
MODIFY I_RECORD FROM WA_RECORD
TRANSPORTING DEL_FLAG
ERR_MSG
WHERE LIFNR = WA_RECORD-LIFNR
AND EVART = WA_RECORD-EVART
AND EKORG = WA_RECORD-EKORG
AND EKGRP = WA_RECORD-EKGRP
AND WERKS = WA_RECORD-WERKS
AND LGORT = WA_RECORD-LGORT
AND KDATB = WA_RECORD-KDATB
AND KDATE = WA_RECORD-KDATE.
* Checking for Material under the Plant for Agreement Type 'WK'
ELSEIF WA_RECORD-EVART = C_WK.
READ TABLE I_MATNR INTO WA_MATNR
WITH KEY MATNR = WA_RECORD-EMATN
BINARY SEARCH.
IF SY-SUBRC NE 0.
V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES. "Inpfle err.ocrd
WA_RECORD-ERR_MSG = TEXT-006.
WA_RECORD-DEL_FLAG = C_TRUE. "marking the record
MODIFY I_RECORD FROM WA_RECORD
TRANSPORTING DEL_FLAG
ERR_MSG
WHERE LIFNR = WA_RECORD-LIFNR
AND EVART = WA_RECORD-EVART
AND EKORG = WA_RECORD-EKORG
AND EKGRP = WA_RECORD-EKGRP
AND WERKS = WA_RECORD-WERKS
AND LGORT = WA_RECORD-LGORT
AND KDATB = WA_RECORD-KDATB
AND KDATE = WA_RECORD-KDATE
AND ZTERM = WA_RECORD-ZTERM
AND KTWRT = WA_RECORD-KTWRT
AND EPSTP = WA_RECORD-EPSTP
AND EMATN = WA_RECORD-EMATN.
ENDIF.
ENDIF. " checking of deletion indicator
ENDIF. " checking for success of vendor cross reference
ELSE.
V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES. "Inpfle err.ocrd
WA_RECORD-ERR_MSG = TEXT-041.
WA_RECORD-DEL_FLAG = C_TRUE. "marking the record
MODIFY I_RECORD FROM WA_RECORD
TRANSPORTING DEL_FLAG
ERR_MSG
WHERE WERKS = WA_RECORD-WERKS.
ENDIF. " Plant checked to selection screen
ENDIF. " the records for which del_flag is initial
CLEAR: WA_RECORD,
WA_T024E,
WA_ZMVXREF,
WA_LFA1,
WA_LOEKZ,
WA_MATNR,
L_TODAY,
L_STARTDATE_C,
L_ENDDATE_C,
L_STARTDATE,
L_ENDDATE.
ENDLOOP.
LOOP AT I_RECORD INTO WA_RECORD.
IF WA_RECORD-DEL_FLAG = C_TRUE.
APPEND WA_RECORD TO I_ERR_REC.
CLEAR WA_RECORD.
ENDIF.
ENDLOOP.
ELSE.
MESSAGE E000 WITH TEXT-013. " no records in the flat file
STOP.
ENDIF.
ENDFORM. " validate_flatfile_data
*& Form DOWNLOAD_ERROR_FILE
* Downloads all records along with the records encountering the
* input file validation error
FORM DOWNLOAD_ERROR_FILE.
DATA L_ISDIR TYPE C.
IF V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
V_FILENAME = P_IPERR.
* Check for the existence of the file.
IF RB_LOCAL EQ C_TRUE.
CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'
EXPORTING
FNAME = P_IPERR
IMPORTING
ISDIR = L_ISDIR
EXCEPTIONS
FILEINFO_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF L_ISDIR EQ C_TRUE.
MESSAGE I000 WITH TEXT-088.
STOP.
ENDIF.
ENDIF.
IF RB_LOCAL EQ C_TRUE.
* Download the Input Error File.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = V_FILENAME
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = '#'
TABLES
DATA_TAB = I_ERR_REC
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSEIF RB_SERVE EQ C_TRUE.
OPEN DATASET P_IPERR1 FOR OUTPUT IN TEXT MODE.
CHECK SY-SUBRC EQ 0.
CLEAR WA_ERR_REC.
LOOP AT I_ERR_REC INTO WA_ERR_REC.
IF WA_ERR_REC-DEL_FLAG = C_TRUE.
TRANSFER WA_ERR_REC TO P_IPERR1.
ENDIF.
CLEAR WA_ERR_REC.
ENDLOOP.
CLOSE DATASET P_IPERR1.
ENDIF.
ENDIF.
ENDFORM. " DOWNLOAD_ERROR_FILE
*& Form BUILD_BDC_DATA
* Populates BDC for all the fields neccessary for Open Contract Creation
FORM BUILD_BDC_DATA.
DATA: L_MAT_INDEX TYPE I,
L_CON_INDEX TYPE I,
L_SCA_INDEX TYPE I.
CLEAR WA_BDCDATA.
REFRESH: I_BDCDATA,
I_MESSTAB.
* Processing the bdc
CLEAR: WA_RECORD,
WA_RECORDPREV,
VEN_FLAG,
MAT_FLAG.
LOOP AT I_RECORD INTO WA_RECORD.
* Checks for the del_flag of the record.
IF WA_RECORD-DEL_FLAG EQ C_TRUE
OR WA_RECORD-DEL_FLAG EQ C_STRUE.
CLEAR WA_RECORD.
CONTINUE.
ELSE.
IF WA_RECORDPREV-LIFNR NE WA_RECORD-LIFNR
OR WA_RECORDPREV-EVART NE WA_RECORD-EVART
OR WA_RECORDPREV-EKORG NE WA_RECORD-EKORG
OR WA_RECORDPREV-EKGRP NE WA_RECORD-EKGRP
OR WA_RECORDPREV-WERKS NE WA_RECORD-WERKS
OR WA_RECORDPREV-LGORT NE WA_RECORD-LGORT
OR WA_RECORDPREV-KDATB NE WA_RECORD-KDATB
OR WA_RECORDPREV-KDATE NE WA_RECORD-KDATE
OR WA_RECORDPREV-ZTERM NE WA_RECORD-ZTERM
OR WA_RECORDPREV-KTWRT NE WA_RECORD-KTWRT.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0200'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RM06E-LGORT'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
* Cross-Reference check performed for the given Vendors
CLEAR WA_T024E.
READ TABLE I_T024E INTO WA_T024E
WITH KEY EKORG = WA_RECORD-EKORG
BINARY SEARCH.
IF SY-SUBRC EQ 0.
CLEAR WA_ZMVXREF.
READ TABLE I_ZMVXREF INTO WA_ZMVXREF
WITH KEY D_ALTKN = WA_RECORD-LIFNR
D_BUKRS = P_BUKRS
BINARY SEARCH.
IF SY-SUBRC EQ 0.
PERFORM BDC_FIELD USING 'EKKO-LIFNR'
WA_ZMVXREF-M_ALTKN.
ENDIF.
CLEAR WA_ZMVXREF.
ENDIF.
CLEAR WA_T024E.
PERFORM BDC_FIELD USING 'RM06E-EVART'
WA_RECORD-EVART.
PERFORM BDC_FIELD USING 'EKKO-EKORG'
WA_RECORD-EKORG.
PERFORM BDC_FIELD USING 'EKKO-EKGRP'
WA_RECORD-EKGRP.
PERFORM BDC_FIELD USING 'RM06E-WERKS'
WA_RECORD-WERKS.
PERFORM BDC_FIELD USING 'RM06E-LGORT'
WA_RECORD-LGORT.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0201'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'EKKO-KTWRT'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=AB'.
PERFORM CONVERT_DATE USING WA_RECORD-KDATB V_CONV_DATE.
PERFORM BDC_FIELD USING 'EKKO-KDATB'
V_CONV_DATE.
PERFORM CONVERT_DATE USING WA_RECORD-KDATE V_CONV_DATE.
PERFORM BDC_FIELD USING 'EKKO-KDATE'
V_CONV_DATE.
PERFORM BDC_FIELD USING 'EKKO-ZTERM'
WA_RECORD-ZTERM.
PERFORM BDC_FIELD USING 'EKKO-KTWRT'
WA_RECORD-KTWRT.
VEN_FLAG = 1.
L_MAT_INDEX = 1. "index for table-control of material
ENDIF.
* "first check for itemline
IF WA_RECORDPREV-EPSTP NE WA_RECORD-EPSTP
OR WA_RECORDPREV-EMATN NE WA_RECORD-EMATN
OR WA_RECORDPREV-KTMNG NE WA_RECORD-KTMNG
OR WA_RECORDPREV-NETPR NE WA_RECORD-NETPR
OR WA_RECORDPREV-PEINH NE WA_RECORD-PEINH
OR WA_RECORDPREV-BPRME NE WA_RECORD-BPRME
OR WA_RECORDPREV-IDNLF NE WA_RECORD-IDNLF
OR WA_RECORDPREV-WEBRE NE WA_RECORD-WEBRE
OR WA_RECORDPREV-MEPRF NE WA_RECORD-MEPRF
OR WA_RECORDPREV-LTEX1 NE WA_RECORD-LTEX1
OR VEN_FLAG EQ 1.
V_IND = L_MAT_INDEX.
IF V_IND GT 1.
V_IND = 2.
ENDIF.
CONCATENATE 'RM06E-EVRTP(' V_IND ')' INTO V_EVRTP1.
CONCATENATE 'RM06E-EPSTP(' V_IND ')' INTO V_EPSTP1.
CONCATENATE 'EKPO-EMATN(' V_IND ')' INTO V_EMATN1.
CONCATENATE 'EKPO-KTMNG(' V_IND ')' INTO V_KTMNG1.
CONCATENATE 'EKPO-NETPR(' V_IND ')' INTO V_NETPR1.
CONCATENATE 'EKPO-PEINH(' V_IND ')' INTO V_PEINH1.
CONCATENATE 'EKPO-BPRME(' V_IND ')' INTO V_BPRME1.
CONCATENATE 'RM06E-TCSELFLAG(' V_IND ')' INTO V_TCSELFLAG1.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0220'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=NP'.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0220'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
V_EVRTP1.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=DETA'.
PERFORM BDC_FIELD USING V_EPSTP1
WA_RECORD-EPSTP.
PERFORM BDC_FIELD USING V_EMATN1
WA_RECORD-EMATN.
PERFORM BDC_FIELD USING V_KTMNG1
WA_RECORD-KTMNG.
PERFORM BDC_FIELD USING V_NETPR1
WA_RECORD-NETPR.
PERFORM BDC_FIELD USING V_PEINH1
WA_RECORD-PEINH.
PERFORM BDC_FIELD USING V_BPRME1
WA_RECORD-BPRME.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0211'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'EKPO-WEBRE'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=DETZ'.
PERFORM BDC_FIELD USING 'EKPO-IDNLF'
WA_RECORD-IDNLF.
TRANSLATE WA_RECORD-EVART TO UPPER CASE.
IF WA_RECORD-EVART EQ C_WK.
PERFORM BDC_FIELD USING 'EKPO-WEBRE' 'X'.
ENDIF.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0212'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'EKPO-MEPRF'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=TXP'.
PERFORM BDC_FIELD USING 'EKPO-MEPRF'
WA_RECORD-MEPRF.
IF NOT WA_RECORD-LTEX1 IS INITIAL. "NE space.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0106'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RM06E-SELKZ(02)'.
PERFORM BDC_FIELD -
ABAP XSL mapping - Binary data of attached file
I have a webservice which is converting attachment and putting it into XSLT Node. when I mapped this node to Attachment payload of my partner (using ABAP xsl mapping), I got an error.
I was able to send the same file via SOAP UI...
On further investigation of the http log files, I noticed that Binary data for both streams looked same, but when I did a word count, I noticed that SOAP UI was a single line file while my PI data was more than 400 lines.. so I coded a fn:transfer of this data to convert end of line character to empty value. it did seem to work...
My question, is this approach correct? or is there any way to ensure binary data stream in XML node does not contain those additional characters?can you provide input xml
Edited by: RajuGA on Dec 7, 2011 2:09 PM -
Employee Photo Upload through binary data
Hi all,
I know the Provision for Photo upload through OAAD Tcode, I know FM to upload the photos by giving path as input data. my requirement is I have picture in the form of binary data . i want to upload that into PA30. I have return the following code. No Error but image is not displayed in PA30.Can u Please correct me?
tables: toav0, toaom, twfdb, toapa.
data: key like ojint-key,
object like ojint-name,
object_id like toav0-object_id,
archiv_id like toav0-archiv_id,
arc_doc_id like toav0-arc_doc_id,
ablagedatum like sapb-sapabldate,
ar_date like toav0-ar_date,
del_date like toav0-del_date,
sap_object like toaom-sap_object,
ar_object like toaom-ar_object,
expiry_tim like toaom-expiry_tim,
method like ojint-method,
return like ojint-return,
parameter like ojint-parameter.
data:begin of i_toav0 occurs 1.
include structure toav0.
data: end of i_toav0.
data: begin of i_toaom occurs 1.
include structure toaom.
data: end of i_toaom.
data: begin of fields occurs 1.
include structure ojfields.
data: end of fields.
DATA: filename1 TYPE string.
Data: i_name TYPE STXBITMAPS-TDNAME value 'TEST',
* archiv_id like toav0-archiv_id,
i_id TYPE STXBITMAPS-TDID VALUE 'BMAP',
i_btype TYPE STXBITMAPS-TDBTYPE VALUE 'BCOL',
l_bds_bytecnt TYPE i,
FLENGTH TYPE SAPB-LENGTH,
l_bds_content TYPE TABLE OF bapiconten,
OUTDOC LIKE TOADT ,
wa_l_bds_content TYPE bapiconten.
*DATA : BINARY TYPE STANDARD TABLE OF TBL1024,
data : BINARY TYPE STANDARD TABLE OF TBL1024 WITH HEADER LINE,
ARCHIVOBJECT type standard table of docs,
archiv_doc_id like toav0-arc_doc_id,
wa_binary type TBL1024.
data: lw_ar_object like toaom-ar_object,
lw_object_id like sapb-sapobjid,
lw_sap_object like toaom-sap_object,
lw_doc_type like toadd-doc_type,
lw_path like sapb-sappfad,"toav0-arc_doc_id
* archiv_doc_id like toav0-arc_doc_id,
doc_type like toadt-doc_class.
constants: c_sap_object type toaom-sap_object value 'PREL',
c_ar_object type toaom-ar_object value 'HRICOLFOTO',
c_doc_type type toaom-doc_type value 'JPG'.
PARAMETERS: filename(150) TYPE c OBLIGATORY. "Name of the File where source as txt format
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
PERFORM getfile.
start-of-selection.
filename1 = filename.
key = '010001380002'.
lw_ar_object = c_ar_object.
* lw_object_id = w_pernr_pass.
lw_sap_object = c_sap_object.
lw_doc_type = c_doc_type.
* lw_path = it_data-file_nam.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename1
filetype = 'BIN'
TABLES
data_tab = archivobject.
* Object to be archived
select single * from toaom where ar_object = c_ar_object and sap_object = c_sap_object.
if sy-subrc <> 0.
raise UPLOAD_ERROR.
else.
* Authority check with Archive id
archiv_id = toaom-archiv_id.
perform authority_check_create(oaall)
using archiv_id object space ar_object space
changing sy-subrc.
if sy-subrc ne 0.
raise UPLOAD_ERROR.
else.
if sy-subrc <> 0.
raise UPLOAD_ERROR.
clear toav0.
else." Transfer key for archiving
toav0-object_id = key.
if key eq space.
Raise FUNCTION_ERROR.
clear toav0.
else.
perform create_archive_object_new .
endif.
endif.
endif.
endif.
form create_archive_object_new .
CALL FUNCTION 'ARCHIV_CREATE_TABLE'
EXPORTING
AR_OBJECT = lw_ar_object
* DEL_DATE =
OBJECT_ID = '010001380002'
SAP_OBJECT = lw_sap_object
* FLENGTH = '2328'
DOC_TYPE = lw_doc_type
* DOCUMENT =
* MANDT = SY-MANDT
* IMPORTING
* OUTDOC =
TABLES
ARCHIVOBJECT = ARCHIVOBJECT
* BINARCHIVOBJECT = binary
* EXCEPTIONS
* ERROR_ARCHIV = 1
* ERROR_COMMUNICATIONTABLE = 2
* ERROR_CONNECTIONTABLE = 3
* ERROR_KERNEL = 4
* ERROR_PARAMETER = 5
* ERROR_USER_EXIT = 6
* ERROR_MANDANT = 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.
call function 'ARCHIVOBJECT_CREATE_TABLE'
EXPORTING
archiv_id = archiv_id
document_type = lw_doc_type
* length = '2328'
IMPORTING
archiv_doc_id = i_toav0-arc_doc_id
TABLES
archivobject = archivobject
* binarchivobject = BINARY
EXCEPTIONS
error_kernel = 1
error_communicationtable = 2
error_archiv = 3.
move i_toav0 to toav0.
toav0-sap_object = lw_sap_object.
toav0-object_id = key.
move archiv_id to toav0-archiv_id.
move i_toav0-arc_doc_id to toav0-arc_doc_id.
toav0-ar_object = lw_ar_object.
move lw_doc_type to toav0-reserve.
move lw_doc_type to doc_type.
commit work.
call function 'ARCHIV_CONNECTION_INSERT'
exporting
archiv_id = toav0-archiv_id
arc_doc_id = toav0-arc_doc_id
ar_date = ar_date
ar_object = toav0-ar_object
* DEL_DATE = ' '
* MANDANT = ' '
object_id = '010001380002'
sap_object = toav0-sap_object
doc_type = doc_type
* barcode = barcode
exceptions
error_connectiontable = 1
others = 2
endform.
FORM getfile .
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = ' '
def_path = '*.*'
mask = ''
mode = 'O'
title = ' SELECTING FILE FOR SOURCE PROGRAM'
IMPORTING
filename = filename
EXCEPTIONS
selection_cancel = 3
selection_error = 4.Hi all,
I know the Provision for Photo upload through OAAD Tcode, I know FM to upload the photos by giving path as input data. my requirement is I have picture in the form of binary data . i want to upload that into PA30. I have return the following code. No Error but image is not displayed in PA30.Can u Please correct me?
tables: toav0, toaom, twfdb, toapa.
data: key like ojint-key,
object like ojint-name,
object_id like toav0-object_id,
archiv_id like toav0-archiv_id,
arc_doc_id like toav0-arc_doc_id,
ablagedatum like sapb-sapabldate,
ar_date like toav0-ar_date,
del_date like toav0-del_date,
sap_object like toaom-sap_object,
ar_object like toaom-ar_object,
expiry_tim like toaom-expiry_tim,
method like ojint-method,
return like ojint-return,
parameter like ojint-parameter.
data:begin of i_toav0 occurs 1.
include structure toav0.
data: end of i_toav0.
data: begin of i_toaom occurs 1.
include structure toaom.
data: end of i_toaom.
data: begin of fields occurs 1.
include structure ojfields.
data: end of fields.
DATA: filename1 TYPE string.
Data: i_name TYPE STXBITMAPS-TDNAME value 'TEST',
* archiv_id like toav0-archiv_id,
i_id TYPE STXBITMAPS-TDID VALUE 'BMAP',
i_btype TYPE STXBITMAPS-TDBTYPE VALUE 'BCOL',
l_bds_bytecnt TYPE i,
FLENGTH TYPE SAPB-LENGTH,
l_bds_content TYPE TABLE OF bapiconten,
OUTDOC LIKE TOADT ,
wa_l_bds_content TYPE bapiconten.
*DATA : BINARY TYPE STANDARD TABLE OF TBL1024,
data : BINARY TYPE STANDARD TABLE OF TBL1024 WITH HEADER LINE,
ARCHIVOBJECT type standard table of docs,
archiv_doc_id like toav0-arc_doc_id,
wa_binary type TBL1024.
data: lw_ar_object like toaom-ar_object,
lw_object_id like sapb-sapobjid,
lw_sap_object like toaom-sap_object,
lw_doc_type like toadd-doc_type,
lw_path like sapb-sappfad,"toav0-arc_doc_id
* archiv_doc_id like toav0-arc_doc_id,
doc_type like toadt-doc_class.
constants: c_sap_object type toaom-sap_object value 'PREL',
c_ar_object type toaom-ar_object value 'HRICOLFOTO',
c_doc_type type toaom-doc_type value 'JPG'.
PARAMETERS: filename(150) TYPE c OBLIGATORY. "Name of the File where source as txt format
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
PERFORM getfile.
start-of-selection.
filename1 = filename.
key = '010001380002'.
lw_ar_object = c_ar_object.
* lw_object_id = w_pernr_pass.
lw_sap_object = c_sap_object.
lw_doc_type = c_doc_type.
* lw_path = it_data-file_nam.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename1
filetype = 'BIN'
TABLES
data_tab = archivobject.
* Object to be archived
select single * from toaom where ar_object = c_ar_object and sap_object = c_sap_object.
if sy-subrc <> 0.
raise UPLOAD_ERROR.
else.
* Authority check with Archive id
archiv_id = toaom-archiv_id.
perform authority_check_create(oaall)
using archiv_id object space ar_object space
changing sy-subrc.
if sy-subrc ne 0.
raise UPLOAD_ERROR.
else.
if sy-subrc <> 0.
raise UPLOAD_ERROR.
clear toav0.
else." Transfer key for archiving
toav0-object_id = key.
if key eq space.
Raise FUNCTION_ERROR.
clear toav0.
else.
perform create_archive_object_new .
endif.
endif.
endif.
endif.
form create_archive_object_new .
CALL FUNCTION 'ARCHIV_CREATE_TABLE'
EXPORTING
AR_OBJECT = lw_ar_object
* DEL_DATE =
OBJECT_ID = '010001380002'
SAP_OBJECT = lw_sap_object
* FLENGTH = '2328'
DOC_TYPE = lw_doc_type
* DOCUMENT =
* MANDT = SY-MANDT
* IMPORTING
* OUTDOC =
TABLES
ARCHIVOBJECT = ARCHIVOBJECT
* BINARCHIVOBJECT = binary
* EXCEPTIONS
* ERROR_ARCHIV = 1
* ERROR_COMMUNICATIONTABLE = 2
* ERROR_CONNECTIONTABLE = 3
* ERROR_KERNEL = 4
* ERROR_PARAMETER = 5
* ERROR_USER_EXIT = 6
* ERROR_MANDANT = 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.
call function 'ARCHIVOBJECT_CREATE_TABLE'
EXPORTING
archiv_id = archiv_id
document_type = lw_doc_type
* length = '2328'
IMPORTING
archiv_doc_id = i_toav0-arc_doc_id
TABLES
archivobject = archivobject
* binarchivobject = BINARY
EXCEPTIONS
error_kernel = 1
error_communicationtable = 2
error_archiv = 3.
move i_toav0 to toav0.
toav0-sap_object = lw_sap_object.
toav0-object_id = key.
move archiv_id to toav0-archiv_id.
move i_toav0-arc_doc_id to toav0-arc_doc_id.
toav0-ar_object = lw_ar_object.
move lw_doc_type to toav0-reserve.
move lw_doc_type to doc_type.
commit work.
call function 'ARCHIV_CONNECTION_INSERT'
exporting
archiv_id = toav0-archiv_id
arc_doc_id = toav0-arc_doc_id
ar_date = ar_date
ar_object = toav0-ar_object
* DEL_DATE = ' '
* MANDANT = ' '
object_id = '010001380002'
sap_object = toav0-sap_object
doc_type = doc_type
* barcode = barcode
exceptions
error_connectiontable = 1
others = 2
endform.
FORM getfile .
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = ' '
def_path = '*.*'
mask = ''
mode = 'O'
title = ' SELECTING FILE FOR SOURCE PROGRAM'
IMPORTING
filename = filename
EXCEPTIONS
selection_cancel = 3
selection_error = 4. -
How to send binary data in the message body
How can we send binary data in the message body that is base64 encoded? below are the requirements
Mime Header.
Mime-version: 1.0
Content-Type: application/octet_stream; name=test
Content-Transfer-Encoding: Base64
Submission must be named "test.sub" (lowercase)
Submission must be base64 mime-encoded
Submission must be sent in the body of the message (not as an attachment)
Only one submission per mail message
No other comments should be put in the body of the mail message (other than the submission)
I highly appreciate your help. If you can provide few examples, that will be very helpfull.
Thanks,
MadanUse Message.setContent to set the content, or use Message.setDataHandler with
a DataHandler constructed with a ByteArrayDataSource. If the content is not
"naturally" encoded in base64, you can enforce it by setting the Content-Transfer-Encoding
header to "base64". Any reasonable mail reader won't care what encoding you use, as
long as the decoded data is correct. -
JPA - Best Practice For Data Transfer?
I've been considering an alternative method for data transfer between applications, by using Serialized or Encoded to File JPA Entities. (either Binary or XML)
I know this procedure may have several draw backs as compared to traditional exported SQL queries or data manipulation statements, however, I want to know if anyone has considered or used this process for data transfer?
The process would be to
- query the database and load the JPA Entities
- Serialize or Encode them to file
- zip up the entire folder with the JPA entities
- transfer the data to destination machine
- extract the data to a temp directory
- reload the JPA entities by de-serializing and persisting them to the database
The reason I'm considering this process, is basically because I have a desktop application (manages member records, names, dates, contributions, etc) used by different organisations in different locations (which are not related except by purpose ie clubs or churches) and would like to have a simple way of transporting all data associated with a single profile (information about a member of the organisation) from one location to another in a simple way, ie users interact only with the application without the need for any database management tool or such.
I'm also considering this because it is not easy to generate an SQL Script file without using a dedicated Database Management Tool, which I do not want the application users to have to learn how to use.
I would appreciate ANY suggestions and probable alternative solutions for this problem. FYI: I'm using a Java DB database.
ICEjschell wrote:
In summary you are moving data from one database to another. True
You only discussed flow one way. Well the process is meant to be bi-directional. Basically what I envision would to have something like:
- the user goes to File -> Export Profile...
- then selects one or more profiles to export
- the export process completes and the zip archive is created and transfered (copied, mailed, etc) to the destination location
then on the destination pc
- the user goes to File -> Import Profile
- selects the profile package
- the app extracts, processes and imports the data (JPA serialized for example)
Flow both ways is significantly more complicated in general.Well if well done it shouldn't be
And what does this have to do with users creating anything?Well as shown above the user would be generating the Zip Archive (assuming that is the final format)
Does this make the problem clearer?
ICE -
Errors and exceptions in writing large binary data on sockets!!! urgent
hi
I am trying to write large binary data in the form of byte arrays on sockets.
Data is as large as 512KB(== 524288bytes) So i store the data (actually read from a file through FileInputStream ) and then write on the socket with lines like this
DataOutputStream dos =
new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
dos.write(b);
/* suppose b is the arrayreference in which data is stored. sometimes i write with that offset + len function*/
dos.flush();
dos.close();
sock.close();
but the program is not stable: sometimes the whole 512KB is read on other side and sometimes less usually 64KB.
The program is unthreaded.
There is another problem : one side(reading or writing) sometimes gives error :
java.net.SocketException: Software caused connection abort: socket write error
please reply and reply soon and give ur suggestions
thankshi
I am trying to write large binary data in theform
of byte arrays on sockets.
Data is as large as 512KB(== 524288bytes) So istore
the data (actually read from a file through
FileInputStream ) and then write on the socketwith
lines like this
DataOutputStream dos =
new DataOutputStream(new
BufferedOutputStream(sock.getOutputStream()));
dos.write(b);
/* suppose b is the arrayreference in which datais
stored. sometimes i write with that offset + len
function*/
dos.flush();
dos.close();
sock.close();
but the program is not stable: sometimes the whole
512KB is read on other side and sometimes less
usually 64KB.
The program is unthreaded.
There is another problem : one side(reading or
writing) sometimes gives error :
java.net.SocketException: Software caused
connection abort: socket write error
please reply and reply soon and give ursuggestions
thanksUmm how are you reading the data on the other side?
some of your code snippet might help. Your writing
code seems ok. I've written a file transfer program
in a similar fashion and have successfully testing on
different platforms (AIX, AS400, Solaris, Windows,
etc) without any problems and without needing to set
the buffer sizes with files as large as 600MB and you
said you're testing this on the loopback?
Point here is you should never need to reset any of the default TCP options to get program correctness. The options are more for optimizations and fine tuning. If indeed you need to change the options to get your program to work, then you program wont be able to scale under different load. -
How to return binary data from a servlet?
This is my problem:
I have a table (generated from a database), and I would like the user to be able to select a one of the items in the table. When the user clicks the link I would like to transfer a piece of binary data stored in my database.
I am quite new to Creator and web apps, so I don't really know the best solution to implement this. I have one requirement: I must log the file transfer in the database (the web-servers log is not good enough...)
Any help would really be appreciated...
TrondHi Trond,
Please have a look at the following thread.
http://swforum.sun.com/jive/thread.jspa?forumID=123&threadID=46410
It discusses how to display an image stored in the database table. This discussion may provide you with useful information.
Hope this helps
Cheers
Giri :-)
Creator Team -
Best way to put binary-data into string?
Hi there!
What I want to do is to transfer binary data via HTTP/GET so what I have to do is to transfer binary data into a string.
Currently I do this the follwing way:
byte[] rawSecData = new byte[4]; //any binary datas
ByteArrayOutputStream secBOS = new ByteArrayOutputStream(4);
DataOutputStream secDOS = new DataOutputStream(secBOS);
for(int i=0; i < rawSecData.length; i++)
secDOS.writeByte(rawSecData);
secDOS.flush();
String secData = secBOS.toString();
System.err.println("Lenght of resulting String: "+secData.length());
I know that this way already worked fine, however I now set up my system up again with another linux-distro and now strange things happen.
e.g. the secData string differs in lenght from run-to-run between 2 and 4 and I don know at all why?
Transferring the binary-stuff into string-stuff (e.g. short-binary 255 255, String: 65536) is not possible for me because of various reasons.
The funny thing is that I remeber that this already worked some time ago and I can figure out why it now doesnt...
Please help!First of all thanks a lot for your help!
Yes, I already think its an encoding problem, but how can I specify the encoding in my application in a portable way. I dont have an idea what to do.
My applikation should run as applet on many different 1.1+ VMS (msjvm, netscape-1.1.5, ...).
Thanks again, lg Clemens -
Conversion from scaled ton unscaled data using Graph Acquired Binary Data
Hello !
I want to acquire temperature with a pyrometer using a PCI 6220 (analog input (0-5V)). I'd like to use the VI
Cont Acq&Graph Voltage-To File(Binary) to write the data into a file and the VI Graph Acquired Binary Data to read it and analyze it. But in this VI, I didn't understand well the functionnement of "Convert unscaled to scaled data", I know it takes informations in the header to scale the data but how ?
My card will give me back a voltage, but how can I transform it into temperature ? Can I configure this somewhere, and then the "Convert unscaled to scaled data" will do it, or should I do this myself with a formula ?
Thanks.Nanie, I've used these example extensively and I think I can help. Incidently, there is actually a bug in the examples, but I will start a new thread to discuss this (I haven't written the post yet, but it will be under "Bug in Graph Acquired Binary Data.vi:create header.vi Example" when I do get around to posting it). Anyway, to address your questions about the scaling. I've included an image of the block diagram of Convert Unscaled to Scaled.vi for reference.
To start, the PCI-6220 has a 16bit resolution. That means that the range (±10V for example) is broken down into 2^16 (65536) steps, or steps of ~0.3mV (20V/65536) in this example. When the data is acquired, it is read as the number of steps (an integer) and that is how you are saving it. In general it takes less space to store integers than real numbers. In this case you are storing the results in I16's (2 bytes/value) instead of SGL's or DBL's (4 or 8 bytes/value respectively).
To convert the integer to a scaled value (either volts, or some other engineering unit) you need to scale it. In the situation where you have a linear transfer function (scaled = offset + multiplier * unscaled) which is a 1st order polynomial it's pretty straight forward. The Convert Unscaled to Scaled.vi handles the more general case of scaling by an nth order polynomial (a0*x^0+a1*x^1+a2*x^2+...+an*x^n). A linear transfer function has two coefficients: a0 is the offset, and a1 is the multiplier, the rest of the a's are zero.
When you use the Cont Acq&Graph Voltage-To File(Binary).vi to save your data, a header is created which contains the scaling coefficients stored in an array. When you read the file with Graph Acquired Binary Data.vi those scaling coefficients are read in and converted to a two dimensional array called Header Information that looks like this:
ch0 sample rate, ch0 a0, ch0 a1, ch0 a2,..., ch0 an
ch1 sample rate, ch1 a0, ch1 a1, ch1 a2,..., ch1 an
ch2 sample rate, ch2 a0, ch2 a1, ch2 a2,..., ch2 an
The array then gets transposed before continuing.
This transposed array, and the unscaled data are passed into Convert Unscaled to Scaled.vi. I am probably just now getting to your question, but hopefully the background makes the rest of this simple. The Header Information array gets split up with the sample rates (the first row in the transposed array), the offsets (the second row), and all the rest of the gains entering the for loops separately. The sample rate sets the dt for the channel, the offset is used to intialize the scaled data array, and the gains are used to multiply the unscaled data. With a linear transfer function, there will only by one gain for each channel. The clever part of this design is that nothing has to be changed to handle non-linear polynomial transfer functions.
I normally just convert everything to volts and then manually scale from there if I want to convert to engineering units. I suspect that if you use the express vi's (or configure the task using Create DAQmx Task in the Data Neighborhood of MAX) to configure a channel for temperature measurement, the required scaling coefficients will be incorporated into the Header Information array automatically when the data is saved and you won't have to do anything manually other than selecting the appropriate task when configuring your acquisition.
Hope this answers your questions.
ChrisMessage Edited by C. Minnella on 04-15-2005 02:42 PM
Attachments:
Convert Unscaled to Scaled.jpg 81 KB -
Download Binary Data File over Serial Port
I need help setting up a .vi that I can use to download a binary data file from a dos-based system. I will send the system a command, say ascii "DOWNLOAD", and then the remote system will send me a binary data file that will be approx. 600MB. I won't be doing any display/manipulation using labview, I will just need to have the option available in LV to recieve the file.
Any examples would help a programmer that is new to LV and is getting a little desperate.A VISA Read doesn't care whether the data it's getting is binary or ASCII. Where you might have problems is detecting that file transfer is complete. If you have enable termination character set to True in the VISA Configure Serial Port, the read will stop as soon as the termination character is detected. The default termination character is 0xA or a linefeed. You probably don't want to use this. If the file is terminated with a character or string of characters that you now will be unique, you can use this. If there is no unique termination character at the end of the file, the next best thing is to know the file size exactly and set the byte count of VISA Read to that number. Based on file size and baud rate, you would also need to adjust the VISA timeout value. Another way to do this is to transfer the data in pieces and write to a file as soon as the data is received. The reading of data would then be terminated when there are no more bytes available at the serial port. I've attached a LabVIEW 7.0 program that should give an idea of the last approach.
Attachments:
File Transfer.vi 57 KB
Maybe you are looking for
-
Java jvm server mode memory leak out of memory crash
Hi, I am using java version "1.6.0_13" on a windows 2003 server. I am running apache-tomcat-6.0.18 PermSize:256M HEAP:1G If tomcat is started with java with client mode vm, the site works very well! Requests are processed without problems and memory
-
im using macbook pro 11in ... i had recently ungraded to os x lion through app store .... i was working on my laptop with firefox open .. i closed my macbook just as i normally do to make it go to sleep (not shutdown) ... i went hope i opend it and i
-
Is there any way to do text column selection and editing with JDeveloper? Why is column selection so often overlooked in editors such as JDeveloper and Eclipse while editors I've used years ago (Brief, UltraEdit, MultiEdit, etc) had great support for
-
Missing "foreground to transparent" gradient in Elements 8
I could have sworn it was there yesterday but, I can't find, "foreground to transparent"! 1. How can I get it back? 2. Where did it go? (I know where it is SUPPOSED to be, it's just not there) Thanks!
-
I am trying to down loading Lightroom 5
Is this where you post a message? Well I made the pruchase and want to down load Lightroom 5.