‎2008 Apr 13 6:01 PM
Hi all,
I have a quick question w.r.t a program for BDC Table control. I have written a dialog program containing one screen based on all the fields from the table SBOOK. Whatever the data entered into those fields will be inserted into the database table.
Now i would like to write a BDC program for the above transaction.
While creating an internal table structure, I have browsed the Data elements of table SBOOK. I found a field FLDATE with length 8. Shall i declare it an 8 or 10 ????
Now my question is, whether i should declare the length of the fields in internal table same as that of Database table or else i can declare my custom lengths.
Thanks.
Shiv
‎2008 Apr 13 7:44 PM
‎2008 Apr 13 7:44 PM
‎2008 Apr 13 8:50 PM
HI I AM PUTTING MY CODE OVER HERE.
report ZVKBDCTRANSACTION
no standard page heading line-size 255.
DATA : BEGIN OF IT_DUMMY OCCURS 0,
DUMMY(100) TYPE C,
END OF IT_DUMMY.
DATA : BEGIN OF ITAB OCCURS 0,
CARRID(3) TYPE C,
CONNID(4) TYPE C,
FLDATE(11) TYPE C,
PRICE(15) TYPE C,
PLANETYPE(10) TYPE C,
END OF ITAB.
DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = 'C:\USERS\VAMC\DOCUMENTS\FLINFO1.TXT'
TABLES
data_tab = IT_DUMMY
.
IF sy-subrc <> 0.
WRITE 'ERROR'.
ENDIF.
LOOP AT IT_DUMMY.
ITAB-CARRID = IT_DUMMY-DUMMY+0(3).
ITAB-CONNID = IT_DUMMY-DUMMY+3(4).
ITAB-FLDATE = IT_DUMMY-DUMMY+7(11).
ITAB-PRICE = IT_DUMMY-DUMMY+18(15).
ITAB-PLANETYPE = IT_DUMMY-DUMMY+33(10).
APPEND ITAB.
ENDLOOP.
*LOOP AT ITAB.
*WRITE: ITAB-CARRID, ITAB-CONNID, ITAB-FLDATE, ITAB-PRICE, ITAB-PLANETYPE.
*ENDLOOP.
include bdcrecx1.
start-of-selection.
LOOP AT ITAB.
perform open_group.
perform bdc_dynpro using 'SAPMZ_TPSCREEN02' '1000'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'BDC_CURSOR'
'SFLIGHT-PLANETYPE'.
perform bdc_field using 'SFLIGHT-CARRID'
'AA'.
perform bdc_field using 'SFLIGHT-CONNID'
'17'.
perform bdc_field using 'SFLIGHT-FLDATE'
'12/02/2009'.
perform bdc_field using 'SFLIGHT-PRICE'
'3355'.
perform bdc_field using 'SFLIGHT-PLANETYPE'
'737-200SF'.
perform bdc_dynpro using 'SAPMZ_TPSCREEN02' '1000'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_field using 'BDC_CURSOR'
'SFLIGHT-CARRID'.
perform bdc_field using 'SFLIGHT-CARRID'
'AA'.
perform bdc_field using 'SFLIGHT-CONNID'
'17'.
perform bdc_field using 'SFLIGHT-FLDATE'
'12/02/2009'.
perform bdc_field using 'SFLIGHT-PRICE'
'3.355,00'.
perform bdc_field using 'SFLIGHT-PLANETYPE'
'737-200SF'.
perform bdc_transaction using 'Z_TPSCREEN02'.
perform close_group.
ENDLOOP.
My Flat file Contains 3 records.
AA 0017 10/11/2006 6655 737-200
LH 0400 11/12/2005 3322 737-200SF
AA 0017 10/11/2004 4433 737-200
After Executing this code
It generated all return codes 0.
I don't know what a return code 0 means.
I went to SM35 and processed my session in the background.
To my surprise, I didn't find my session in any tabs, Its missing.
Do you have any idea what has happened exactly.
Thanks for your time.
Shiv
‎2008 Apr 13 9:09 PM
Well if you did process this report in background, you will probably find a short dump in ST22 for it, since you are using WS_UPLOAD. WS stands for WorkStation. However, if you are processing in background, you can't upload a file from your local workstation, since the program will be running on application server.
If you want to upload a file in background, you will have to upload it from application server. Put file on application server using transaction cg3z. If record size is too long, find someone from basis to put file on application server, or write a report yourself to do this.
Return code sy-subrc = 0, means that 'everything' is OK.
sy-subrc = 4, normally states that there is an error, however when transporting development objects from A to B, sy-subrc = 4, is still ok, but some warnings.
Every return code > 4, is (mayor) error.
Edited by: Micky Oestreich on Apr 13, 2008 10:12 PM
‎2008 Apr 14 3:30 AM
hi Shiva,
You have check the 'KEEP SESSSION' in your selection screen to keep your session in SM35 after processing else by default deletes the session after processing.
So rerun the transaction with checking the checkbox.
Hope this helps you.
Thanks,
Arun
‎2008 Apr 14 5:44 AM
Thanks Arun,
I am able see my session in Processed Tab. Thanks.
‎2008 Apr 14 10:33 AM
Hi Shivaram..
You Can specify field lengths as per the database table..
Hope its Help full...
Regards,
Rahul