Error log with session method
hi frnds
we can handle error in call transaction method by using bdcmsgcoll,
error is handled by system using session method and these errors can be analysed by going to tr sm35 . <b>is there is any way by which i will use session method in my program and all the errors will be written in the o/p of the list.
is this is possible , if so pls give me some sample code</b>
thanks
pankaj
Hi,
check the belwo sample code.
Declaration of local constants
CONSTANTS : lc_tcode TYPE tstc-tcode VALUE 'ME31K',
lc_n TYPE ctu_mode VALUE 'N'.
Declaration of local variables
DATA: lv_msg TYPE string,
lv_subrc LIKE sy-subrc,
lv_opt TYPE ctu_params.
lv_opt-defsize = c_x.
lv_opt-dismode = lc_n.
lv_opt-updmode = c_l.
REFRESH i_messtab.
Call the transaction to create the Purchasing Contracts
CALL TRANSACTION lc_tcode USING i_bdcdata
OPTIONS FROM lv_opt
MESSAGES INTO i_messtab.
MOVE sy-subrc TO lv_subrc.
IF lv_subrc NE 0.
v_err_cnt = v_err_cnt + 1.
IF NOT i_messtab[] IS INITIAL.
READ TABLE i_messtab WITH KEY msgtyp = 'E'.
IF sy-subrc EQ 0.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = i_messtab-msgid
lang = sy-langu
no = i_messtab-msgnr
v1 = i_messtab-msgv1
v2 = i_messtab-msgv2
v3 = i_messtab-msgv3
v4 = i_messtab-msgv4
IMPORTING
msg = lv_msg.
MOVE: p_wa_header-lifnr TO wa_error-lifnr,
p_wa_header-evart TO wa_error-evart,
p_wa_header-vedat TO wa_error-vedat,
p_wa_header-ekorg TO wa_error-ekorg,
p_wa_header-ekgrp TO wa_error-ekgrp,
p_wa_header-epstp TO wa_error-epstp,
p_wa_header-knttp TO wa_error-knttp,
p_wa_header-bukrs TO wa_error-bukrs,
p_wa_header-kdatb TO wa_error-kdatb,
p_wa_header-kdate TO wa_error-kdate,
p_wa_header-ktwrt TO wa_error-ktwrt,
p_wa_header-waers TO wa_error-waers,
p_wa_header-wkurs TO wa_error-wkurs,
p_wa_header-inco1 TO wa_error-inco1,
p_wa_header-inco2 TO wa_error-inco2,
p_wa_header-ihran TO wa_error-ihran,
p_wa_header-angnr TO wa_error-angnr,
lv_msg TO wa_error-msg.
APPEND wa_error TO i_error.
CLEAR wa_error.
ELSE.
READ TABLE i_messtab WITH KEY msgtyp = 'S'.
IF sy-subrc EQ 0.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = i_messtab-msgid
lang = sy-langu
no = i_messtab-msgnr
v1 = i_messtab-msgv1
v2 = i_messtab-msgv2
v3 = i_messtab-msgv3
v4 = i_messtab-msgv4
IMPORTING
msg = lv_msg.
ENDIF.
ENDIF.
ENDIF.
ELSE.
v_cnt = v_cnt + 1.
ENDIF.
REFRESH i_bdcdata.
*& Form prepare_field_catalog
Prepare Field catalog
<--P_I_FIELDCAT[] Internal table for Field Catalog
FORM prepare_field_catalog CHANGING pt_fieldcat TYPE t_fieldcat.
Declaration of local workarea
DATA: lwa_fieldcat TYPE slis_fieldcat_alv.
Declaration of local constants
CONSTANTS : lc_long_text(1) TYPE c VALUE 'L'.
*--Call the functino module to get the field catalog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'I_SUCCESS'
i_inclname = sy-repid
CHANGING
ct_fieldcat = pt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
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 pt_fieldcat INTO lwa_fieldcat.
CASE lwa_fieldcat-fieldname.
WHEN 'VEDAT'.
lwa_fieldcat-ddictxt = lc_long_text.
lwa_fieldcat-seltext_l = text-004.
MODIFY i_fieldcat FROM lwa_fieldcat
INDEX sy-tabix TRANSPORTING ddictxt seltext_l .
CLEAR lwa_fieldcat.
WHEN 'KDATB'.
lwa_fieldcat-ddictxt = lc_long_text.
lwa_fieldcat-seltext_l = text-005.
MODIFY i_fieldcat FROM lwa_fieldcat
INDEX sy-tabix TRANSPORTING ddictxt seltext_l .
CLEAR lwa_fieldcat.
WHEN 'KDATE'.
lwa_fieldcat-ddictxt = lc_long_text.
lwa_fieldcat-seltext_l = text-006.
MODIFY i_fieldcat FROM lwa_fieldcat
INDEX sy-tabix TRANSPORTING ddictxt seltext_l .
CLEAR lwa_fieldcat.
WHEN 'IHRAN'.
lwa_fieldcat-ddictxt = lc_long_text.
lwa_fieldcat-seltext_l = text-007.
MODIFY i_fieldcat FROM lwa_fieldcat
INDEX sy-tabix TRANSPORTING ddictxt seltext_l .
CLEAR lwa_fieldcat.
ENDCASE.
ENDLOOP. "LOOP AT pt_fieldcat INTO lwa_fieldcat.
ENDIF. "IF sy-subrc <> 0
ENDFORM. " prepare_field_catalog
*& Form display_output
To display the success contracts output in ALV
FORM display_output .
Declaration of local workarea
DATA : lwa_layout TYPE slis_layout_alv.
Declaration of local constants
CONSTANTS : lc_chk(1) TYPE c VALUE 'X',
lc_page TYPE slis_formname VALUE 'SUB_TOP_OF_PAGE'.
Subroutine to prepare the Field Catalog
PERFORM prepare_field_catalog CHANGING i_fieldcat[].
Subroutine to build layout
lwa_layout-box_tabname = 'I_SUCCESS'.
lwa_layout-no_input = lc_chk.
lwa_layout-colwidth_optimize = lc_chk.
lwa_layout-zebra = lc_chk.
lwa_layout-cell_merge = lc_chk.
FM to call the ALV Grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_bypassing_buffer = c_x
i_callback_top_of_page = lc_page
is_layout = lwa_layout
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = i_success
EXCEPTIONS
program_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.
ENDFORM. " display_output
Rewrad if helpful.
Regards,
Nagaraj
Similar Messages
-
Hello friends,
Is it possible to create error log in session method, just like call transaction ( BDCMSGCOLL) . I want to create error log.
Is it possible or not, If possible how ?
Please let me know the answer.
Thanks,
AjayHi,
* To catch no. of lines in itab.
DESCRIBE TABLE itab LINES trec.
* To catch no. of lines in it_err.
DESCRIBE TABLE it_err LINES erec.
* Calculation for records which are successfully uploaded.
srec = trec - erec.
* Layout for display summary begin.
WRITE:(60) sy-uline..
WRITE:/ sy-vline, ' SUMMARY OF TRANSACTION '
COLOR COL_HEADING,60 sy-vline..
WRITE:/(60) sy-uline..
WRITE:/ sy-vline, 'TOTAL NO. OF RECORDS ' COLOR
COL_TOTAL, 46 sy-vline, 50 trec LEFT-JUSTIFIED, 60 sy-vline.
WRITE:/(60) sy-uline.
WRITE:/ sy-vline, 'No Of Records Not Uploaded Successfully are:' COLOR
COL_NEGATIVE HOTSPOT ON,50 erec LEFT-JUSTIFIED, 46 sy-vline,60
sy-vline.
WRITE:/(60) sy-uline.
WRITE:/ sy-vline, 'No Of Records Uploded Successfully are: ' COLOR
COL_POSITIVE ,50 srec LEFT-JUSTIFIED,46 sy-vline,60 sy-vline.
WRITE:/(60) sy-uline.
* Function to create error file.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = 'C:\ERRORS.TXT'
filetype = 'DAT'
TABLES
data_tab = it_err.
* Subroutine for bdc_dynpro.
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
* Subroutine for bdc_field.
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "BDC_FIELD
* Subroutine for bdc_transaction.
FORM bdc_transaction USING tcode.
DATA text(74).
DATA text1(34).
DATA text2(20).
text1 = 'Uploading Data for MATERIAL(MAKTX):' .
text2 = '---PLEASE WAIT.'.
CONCATENATE text1 itab-MAKTX text2 INTO text.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = text
EXCEPTIONS
OTHERS = 1.
REFRESH messtab.
CALL TRANSACTION tcode USING bdcdata
MODE 'N'
* MODE 'A'
UPDATE 'S'
MESSAGES INTO messtab.
l_subrc = sy-subrc.
* Moving data to it_trec.
MOVE l_subrc TO it_trec-rtcode.
MOVE itab-line TO it_trec-rec.
MOVE itab-MAKTX TO it_trec-MAKTX.
MOVE itab-MATKL TO it_trec-MATKL.
APPEND it_trec.
* Looping in bdcmsgcoll structure.
LOOP AT messtab.
SELECT SINGLE * FROM t100 WHERE sprsl = messtab-msgspra
AND arbgb = messtab-msgid
AND msgnr = messtab-msgnr.
IF sy-subrc = 0.
l_mstring = t100-text.
IF l_mstring CS '&1'.
REPLACE '&1' WITH messtab-msgv1 INTO l_mstring.
REPLACE '&2' WITH messtab-msgv2 INTO l_mstring.
REPLACE '&3' WITH messtab-msgv3 INTO l_mstring.
REPLACE '&4' WITH messtab-msgv4 INTO l_mstring.
ELSE.
REPLACE '&' WITH messtab-msgv1 INTO l_mstring.
REPLACE '&' WITH messtab-msgv2 INTO l_mstring.
REPLACE '&' WITH messtab-msgv3 INTO l_mstring.
REPLACE '&' WITH messtab-msgv4 INTO l_mstring.
ENDIF.
CONDENSE : l_mstring.
MOVE l_mstring TO it_trec-mess.
MODIFY it_trec INDEX sy-tabix.
ENDIF.
ENDLOOP.
FORMAT COLOR 4.
* Catching error records from it_trec & moving to it_err.
LOOP AT it_trec WHERE rtcode <> 0.
MOVE-CORRESPONDING it_trec TO it_err.
APPEND it_err.
ENDLOOP.
REFRESH it_trec.
REFRESH bdcdata.
Nikhil.
Edited by: Nikhil Kanegaonkar on May 27, 2009 2:31 PM -
Error message log in session method of ALV report,
In ALV report please let me know:
1) In session method:
where all error messages are stored,I know that error messages are stored in a log file, so please tell me where is it stored.
2)transaction method:
How to handle error messages in transaction methos(for eg if a weight field text box value is negative)Ans for 2nd point.
CALL TRANSACTION c_mb USING i_bdcdata
MODE g_ctumode
UPDATE g_cupdate
MESSAGES INTO i_messtab.
COMMIT WORK.
IF sy-subrc EQ 0. " BDC Executed Successfully
CLEAR wa_messtab.
LOOP AT i_messtab INTO wa_messtab .
IF wa_messtab-msgtyp = 'S' AND
wa_messtab-msgid = 'M7' AND
wa_messtab-msgnr = '060'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = wa_messtab-msgid
msgnr = wa_messtab-msgnr
msgv1 = wa_messtab-msgv1
msgv2 = wa_messtab-msgv2
msgv3 = wa_messtab-msgv3
msgv4 = wa_messtab-msgv4
IMPORTING
message_text_output = l_msg.
APPEND l_msg TO i_sucsess.
CLEAR l_msg.
g_docsuc = 1.
ELSE.
IF wa_messtab-msgtyp = 'E'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = wa_messtab-msgid
msgnr = wa_messtab-msgnr
msgv1 = wa_messtab-msgv1
msgv2 = wa_messtab-msgv2
msgv3 = wa_messtab-msgv3
msgv4 = wa_messtab-msgv4
IMPORTING
message_text_output = l_msg.
g_errflg = 1.
APPEND l_msg TO i_error.
CLEAR: l_msg.
ENDIF. -
How to handle the errors in BDC Session method
Hi All,
I am uploading Material Master (MM01) records using BDC Session Method.my problem is when i am running the program, all the error records are going to flat file.how can i correcting the error records and after correction how can i re-process the error records.tell me with example.
i have around 70,000 records in my flat file.Hi,
I am attaching few threads.Hope these will help you.
If there are any error records in session, all those error records will get poulated in log .SM35 and after the session is completed , u can see error records which can be corrected and reprocessed again
We have the structures BDCLD and BDCLM, which will capture the log details inthe session. Firstly, sesssion should be processed. After that log will be created. Then caputure the information into an internal table using BDCLM and BDCLD.
and refer the link.
error correction in bdc session
regards
Madhu -
hi all,
i need to upload these transactions(MB1A, MB31,MB1A )one after the other.i have the data in flat file(excel). I need to use BDC for this. I am prefering SESSION method for this.Can any one help me to acieve this. shall i record the transactions one after the othet and keep BDC_INSERT after the perform statements. will achieve this. Help me with a sample code for thisHi Kiran,
Upload data into internal table (itab) using the below function modules.And then by using session method populate that in the BDCDATA internal table as you generally do session method.
PARAMETERS: filename LIKE rlgrap-filename .
PARAMETERS: kzheader AS CHECKBOX.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
mask = '*.xls'
static = 'X'
CHANGING
file_name = filename.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = filename
i_begin_col = begcol
i_begin_row = begrow
i_end_col = endcol
i_end_row = endrow
TABLES
intern = itab
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
WRITE:/ 'Upload Error ', SY-SUBRC.
ENDIF.
Reward points if useful.
Thanks & Regards,
khan.
Edited by: Ahmed Khan on Apr 29, 2008 8:01 AM -
RT system error logs - delete session not working
I cannot seem to delete the error logs in my RT system. I right-click, view the logs and select "delete session" they disappear. I select "done". But when I right click to view the log again they're back. Ideas? Thanks in advance.
PaulG.
"I enjoy talking to you. Your mind appeals to me. It resembles my own mind except that you happen to be insane." -- George OrwellHi Paul,
Which version of Real-Time are you working with? Do you have any other RT systems that are demonstrating the same behavior?
Best regards,
-Tim -
DML Error Logging with multiple tables = OALL8
I have a mapping that, via a splitter, loads 3 tables. This mapping works perfectly.
Recently we upgraded to OWB 10.2.0.3 so we decided to make use of the new feature of DML error logging. So three error-tables where created and the "error table name" property of each table was entered. When re-creating this mapping in the database the following errors occur: "State of OALL8 is inconsistent", "No more data to read from Socket" (translated from dutch). When removing the value from the "error table name" property again, the mapping can be recreated again.
What am I doing wrong? Have I run into a bug?Which database version are you using?
Also not sure when exactly the error occurs, when you deploy the map...or when you execute the map? Can you describe as simple a scenario for it to fail that you can?
I did find a bug 5942415 which was to do with this area..worth checking anyway.
Cheers
David -
DML Error logging with delete restrict
Hi,
I am trying to log all DML errors while performing ETL process. We encountered a problem in the process when one of the on delete cascade is missing in child tables but I was curious to know why we got that exception to the calling environment because we are logging all DML errors in err$_ tables. Our expectation is when we get child record found violation then that error will be logged into ERR$_ tables and process will carry on without any interruption but it interrupted in the middle and terminated. I can illustrate with below example
T1 -> T2 -> T3
T1 is parent and it is s root
Create table t1 (id number primary key, id2 number);
Create table t2(id number references t1(id) on delete cascade, id2 number);
create table t3 (id number references t2(id)); -- Missing on delete cascade
insert into t1 as select level, level from dual connect by level < 20;
insert into t2 as select level, level from dual connect by level < 20;
insert into t3 as select level from dual connect by level < 20;
exec dbms_errlog(t1);
exec dbms_errlog(t2);
exec dbms_errlog(t3);
delete from t1 where id = 1 log errors into err$_t1 reject limit unlimited; -- Child record found violation due to t3 raised but I am expecting this error will be trapped in log tables.
delete from t2 where id =1 log errors into err$_t2 reject limit unlimited; -- Got the same error child record violation. My expectation error will be logged into log tables.
I am using Oracle 11gR2.
Also, Please let me know if there is any restrictions to use DML error logging in DBMS_PARALLEL_EXECUTE.
Please advise
Thanks,
UmakanthWhat is the error you want me to fix? Missing on delete cascade?
The Code you posted has multiple syntax errors and can't possibly run. You should post code that actually works.
My expectation is all the DML errors will be logged into error logging tables even if it is child record found violation.
delete from t1 where id = 1 log errors into err$_t1 reject limit unlimited; -- Child record found violation due to t3 raised but I am expecting this error will be trapped in log tables.
delete from t2 where id =1 log errors into err$_t2 reject limit unlimited; -- Got the same error child record violation. My expectation error will be logged into log tables.
DML error logging logs DATA. When you delete from T1 there is an error because the T2 child record can NOT be deleted. So the T1 row that was being deleted is logged into the T1 error log table. The request was to delete a T1 row so that is the only request that failed; the child rows in T2 and T3 will not be put into log tables.
Same when you try to delete from T2. The T3 child record can NOT be deleted so the T2 row that was being deleted is logged into the T2 error log table.
The exceptions that occur are NOT logged, only the data that the DML could not be performed on.
After I fixed your code your example worked fine for me and logged into the DML error tables as expected. But I wasn't doing it from a client. -
How to rectify the errors occured during session method
how to rectify the errors occured during session method
HI
When the execution of session is completed: we can check the errors via the log.
Rectification of errors depends on the kind of errors. It is not specific that we have to approach the same way to handle all kinds of errors.
Errors can be due to data format, inconsistency due to the configuration, unavailability of master data...
Kind Regards
Eswar -
FB01 Posting with Session Method
Hi Experts,
I am trying to post the data in FB01 transaction code through POSTING_INTERFACE_START, POSTING_INTERFACE_DOCUMENT, AND POSTING_INTERFACE_END and it is working fine with Call Transaction method but I want in Batch input session method.
Can anyone guide me on the same what i have to do for the same?
Edited by: Rajneesh Gupta on Mar 10, 2010 7:19 AM
Edited by: Rajneesh Gupta on Mar 10, 2010 7:20 AMHi,
check the following coding in the program: RFBIBL01 Batch Input Documents
just identify how it is working
FORM MAPPE_OEFFNEN.
CHECK FUNCTION NE 'D'.
Interne Buchungsschnittstelle initialisieren
CALL FUNCTION 'POSTING_INTERFACE_START'
EXPORTING
I_FUNCTION = FUNCTION
I_CLIENT = BGR00-MANDT
I_GROUP = BGR00-GROUP
I_XBDCC = XBDCC
I_HOLDDATE = BGR00-START
I_KEEP = BGR00-XKEEP
I_MODE = ANZ_MODE
I_UPDATE = UPDATE
I_USER = BGR00-USNAM.
IF FUNCTION = 'B'.
PERFORM LOG_MSG USING C_MSGID 'I' '007'
GROUP_COUNT BGR00-GROUP SPACE SPACE.
ENDIF.
GROUP_OPEN = 'X'.
ENDFORM.
regards,
ashok -
Capturing SQL server error logs with SQL restores
Hi All.
I have a stored procedure which restores a database, the issue I'm having is that when the stored procedure fails due to space issues.
If the stored procedure is executed from SSMS, get error similar to the below.
Msg 3257, Level 16, State 1, Line 1
There is insufficient free space on disk volume 'X:\Datadrive\' to create the database. The database requires 897725691812 additional free bytes, while only 776828129280 bytes are available.
Msg 3119, Level 16, State 4, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
However, looking at the SQL server output file I only see
Msg 3013, RESTORE DATABASE is terminating abnormally.
(1 rows(s) affected)
Msg 50000, Sev 16, State 1, Line 94 : Msg 3013, RESTORE DATABASE is terminating abnormally. [SQLSTATE 42000]
I have the catch block as follows.
SET @Error = ERROR_NUMBER()
SET @ErrorMessage= ERROR_MESSAGE()
SET @ErrorMessage = 'Msg ' + CAST(@Error AS nvarchar) + ', ' + ISNULL(@ErrorMessage,'')
SELECT @ErrorMessage
RAISERROR(@ErrorMessage,16,1) WITH NOWAIT
My objective is that I want to get the first detailed error message in my output file, however I am not sure what is being done incorrectly. The issue is that the error details in the output file doesnt really say what the issue is.
Thanks in advance.Hi,
Can you replace catch block as per below code
DECLARE @ErrorMessage NVARCHAR(4000), @ErrorProc NVARCHAR(126), @ErrorLineNo INT;
-- ERROR HANDLING - Grab Error code and throw
SELECT @ErrorLineNo = ERROR_LINE(), @ErrorMessage = ERROR_MESSAGE(), @ErrorProc = ERROR_PROCEDURE();
RAISERROR('Error %s occurred in %s. Line %d', 16, 1, @ErrorMessage, @ErrorProc, @ErrorLineNo) WITH SETERROR;
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
My Technet Wiki Article
MVP
Thanks for the response.
Can you please confirm what the code will do, the reason I ask is that we have temporarily resolved the space issue. If i want to test this however, I would need to re-create the scenario. I would like to have an understanding of what this code will do.
Thanks in advance. -
Error occured in bdc(session method)
hai,
i was written one bdc program with session method but unfortunatly it's throwing some error like bdc_group is invalid.
this problem happening at when i was going to give the file path through f4 in selection screen it's showing like BDC_OPEN_GROUP, group .. is invalid
iam sending my coding also plz give me the clarifications abt this one.
SESSION METHOD **********************
TYPES : BEGIN OF TY_DATA,
LIFNR TYPE LIFNR,
EKORG TYPE EKORG,
KTOKK TYPE KTOKK,
NAME1 TYPE NAME1_GP,
SORTL TYPE SORTL,
LAND1 TYPE LAND1_GP,
WAERS TYPE BSTWA,
END OF TY_DATA.
DATA : WA_DATA TYPE TY_DATA,
WA_BDCDATA TYPE BDCDATA,
WA_BDCMSGCOLL TYPE BDCMSGCOLL.
DATA : IT_DATA TYPE TABLE OF TY_DATA,
IT_BDCDATA TYPE TABLE OF BDCDATA,
IT_BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL.
DATA : V_FILE TYPE STRING.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER : PA_FILE LIKE FC03TAB-PL00_FILE, "OBLIGATORY default 'C:\MAHESH\IT_FILE.TXT'
P_GROUP LIKE APQI-GROUPID OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_FILE.
PERFORM GET_F4_FOR_FILE USING PA_FILE.
V_FILE = PA_FILE.
PERFORM UPLOAD_FILE_TO_ITAB USING V_FILE CHANGING IT_DATA.
PERFORM OPEN_SESSION USING P_GROUP.
LOOP AT IT_DATA INTO WA_DATA.
REFRESH IT_BDCDATA.
FIRST SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0107' 'X'.
**** FIELD DETAILS
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'RF02K-KTOKK'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '/00'.
**** FILED LIFNR
PERFORM FILL_FIELD_DETAILS USING 'RF02K-LIFNR' WA_DATA-LIFNR.
FIELD EKORG
PERFORM FILL_FIELD_DETAILS USING 'RF02K-EKORG' WA_DATA-EKORG.
**** FIELD KTOKK
PERFORM FILL_FIELD_DETAILS USING 'RF02K-KTOKK' WA_DATA-KTOKK.
SECOND SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0110' 'X'.
FIELD CURSOR
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'lfa1-land1'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
field NAME
PERFORM FILL_FIELD_DETAILS USING 'LFA1-NAME1' WA_DATA-NAME1.
field SORTL
PERFORM FILL_FIELD_DETAILS USING 'LFA1-SORTL' WA_DATA-SORTL.
field LAND1
PERFORM FILL_FIELD_DETAILS USING 'LFA1-LAND1' WA_DATA-LAND1.
THIRD SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0310' 'X'.
FIELD CURSOR
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'LFM1-WAERS'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
******** field SORTL
PERFORM FILL_FIELD_DETAILS USING 'LFM1-WAERS' WA_DATA-WAERS.
PERFORM BDC_INSERT USING 'MK01' IT_BDCDATA.
ENDLOOP.
PERFORM CLOSE_SESSION.
*& Form GET_F4_FOR_FILE
FORM GET_F4_FOR_FILE USING P_PA_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'PA_FILE'
CHANGING
FILE_NAME = PA_FILE.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GET_F4_FOR_FILE
*& Form UPLOAD_FILE_TO_ITAB
FORM UPLOAD_FILE_TO_ITAB USING FP_V_FILE
CHANGING FP_IT_DATA LIKE IT_DATA.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FP_V_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = FP_IT_DATA.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " UPLOAD_FILE_TO_ITAB
*& Form OPEN_SESSION
FORM OPEN_SESSION USING FP_P_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = FP_P_GROUP
HOLDDATE = FILLER8
KEEP = 'X'
USER = SY-UNAME
IF SY-SUBRC = 0.
WRITE : / 'PROCESS THE SESSION',FP_P_GROUP,'USING SM35'.
ENDIF.
ENDFORM. " OPEN_SESSION
*& Form FILL_SCREEN_DETAILS
FORM FILL_SCREEN_DETAILS USING PROGRAM
DYNPRO
DYNBEGIN.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = DYNBEGIN.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDFORM. " FILL_SCREEN_DETAILS
*& Form FILL_FIELD_DETAILS
FORM FILL_FIELD_DETAILS USING FNAM FVAL.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDFORM. " FILL_FIELD_DETAILS
*& Form BDC_INSERT
FORM BDC_INSERT USING FP_TCODE TYPE SYTCODE
FP_IT_BDCDATA LIKE IT_BDCDATA.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = FP_TCODE
TABLES
DYNPROTAB = FP_IT_BDCDATA.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " BDC_INSERT
*& Form CLOSE_SESSION
FORM CLOSE_SESSION .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CLOSE_SESSIONhai,
i was written one bdc program with session method but unfortunatly it's throwing some error like bdc_group is invalid.
this problem happening at when i was going to give the file path through f4 in selection screen it's showing like BDC_OPEN_GROUP, group .. is invalid
iam sending my coding also plz give me the clarifications abt this one.
SESSION METHOD **********************
TYPES : BEGIN OF TY_DATA,
LIFNR TYPE LIFNR,
EKORG TYPE EKORG,
KTOKK TYPE KTOKK,
NAME1 TYPE NAME1_GP,
SORTL TYPE SORTL,
LAND1 TYPE LAND1_GP,
WAERS TYPE BSTWA,
END OF TY_DATA.
DATA : WA_DATA TYPE TY_DATA,
WA_BDCDATA TYPE BDCDATA,
WA_BDCMSGCOLL TYPE BDCMSGCOLL.
DATA : IT_DATA TYPE TABLE OF TY_DATA,
IT_BDCDATA TYPE TABLE OF BDCDATA,
IT_BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL.
DATA : V_FILE TYPE STRING.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER : PA_FILE LIKE FC03TAB-PL00_FILE, "OBLIGATORY default 'C:\MAHESH\IT_FILE.TXT'
P_GROUP LIKE APQI-GROUPID OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_FILE.
PERFORM GET_F4_FOR_FILE USING PA_FILE.
V_FILE = PA_FILE.
PERFORM UPLOAD_FILE_TO_ITAB USING V_FILE CHANGING IT_DATA.
PERFORM OPEN_SESSION USING P_GROUP.
LOOP AT IT_DATA INTO WA_DATA.
REFRESH IT_BDCDATA.
FIRST SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0107' 'X'.
**** FIELD DETAILS
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'RF02K-KTOKK'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '/00'.
**** FILED LIFNR
PERFORM FILL_FIELD_DETAILS USING 'RF02K-LIFNR' WA_DATA-LIFNR.
FIELD EKORG
PERFORM FILL_FIELD_DETAILS USING 'RF02K-EKORG' WA_DATA-EKORG.
**** FIELD KTOKK
PERFORM FILL_FIELD_DETAILS USING 'RF02K-KTOKK' WA_DATA-KTOKK.
SECOND SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0110' 'X'.
FIELD CURSOR
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'lfa1-land1'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
field NAME
PERFORM FILL_FIELD_DETAILS USING 'LFA1-NAME1' WA_DATA-NAME1.
field SORTL
PERFORM FILL_FIELD_DETAILS USING 'LFA1-SORTL' WA_DATA-SORTL.
field LAND1
PERFORM FILL_FIELD_DETAILS USING 'LFA1-LAND1' WA_DATA-LAND1.
THIRD SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0310' 'X'.
FIELD CURSOR
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'LFM1-WAERS'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
******** field SORTL
PERFORM FILL_FIELD_DETAILS USING 'LFM1-WAERS' WA_DATA-WAERS.
PERFORM BDC_INSERT USING 'MK01' IT_BDCDATA.
ENDLOOP.
PERFORM CLOSE_SESSION.
*& Form GET_F4_FOR_FILE
FORM GET_F4_FOR_FILE USING P_PA_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'PA_FILE'
CHANGING
FILE_NAME = PA_FILE.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GET_F4_FOR_FILE
*& Form UPLOAD_FILE_TO_ITAB
FORM UPLOAD_FILE_TO_ITAB USING FP_V_FILE
CHANGING FP_IT_DATA LIKE IT_DATA.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FP_V_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = FP_IT_DATA.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " UPLOAD_FILE_TO_ITAB
*& Form OPEN_SESSION
FORM OPEN_SESSION USING FP_P_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = FP_P_GROUP
HOLDDATE = FILLER8
KEEP = 'X'
USER = SY-UNAME
IF SY-SUBRC = 0.
WRITE : / 'PROCESS THE SESSION',FP_P_GROUP,'USING SM35'.
ENDIF.
ENDFORM. " OPEN_SESSION
*& Form FILL_SCREEN_DETAILS
FORM FILL_SCREEN_DETAILS USING PROGRAM
DYNPRO
DYNBEGIN.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = DYNBEGIN.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDFORM. " FILL_SCREEN_DETAILS
*& Form FILL_FIELD_DETAILS
FORM FILL_FIELD_DETAILS USING FNAM FVAL.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDFORM. " FILL_FIELD_DETAILS
*& Form BDC_INSERT
FORM BDC_INSERT USING FP_TCODE TYPE SYTCODE
FP_IT_BDCDATA LIKE IT_BDCDATA.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = FP_TCODE
TABLES
DYNPROTAB = FP_IT_BDCDATA.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " BDC_INSERT
*& Form CLOSE_SESSION
FORM CLOSE_SESSION .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CLOSE_SESSION -
DISPLAY LOGS INTO REPORT FROM SESSION METHOD
Hi Friends,
I hv created BDC with Session Method For Tcode KO01 in which internal order number generated which i can see in SM35 tcode....
Now I want to print that Internal order number into report.......
so please tell me How can i print that number which is showing in SM35.......?pls,do some reply its argent
-
Regarding call transaction and session method???
HI All,
Cud u pls let me know
1. differences between call transaction and session???
2. Is it possible to schedule call transaction in background?? ( all are saying MODE N = background scheduling in call transaction.......but i dont think so)
3. Is it posible to handle multiple transactions in call transaction ? if so,how?
4. Is it posible to handle multiple transactions in session ? if so,how?
5. How can we see the log in session method????Hi ,
Check this documentation.
About Session method
In this method you transfer data from internal table to database table through sessions.
In this method, an ABAP/4 program reads the external data that is to be entered in the SAP System and stores the data in session. A session stores the actions that are required to enter your data using normal SAP transaction i.e., Data is transferred to session which in turn transfers data to database table.
Session is intermediate step between internal table and database table. Data along with its action is stored in session i.e., data for screen fields, to which screen it is passed, the program name behind it, and how the next screen is processed.
When the program has finished generating the session, you can run the session to execute the SAP transactions in it. You can either explicitly start and monitor a session or have the session run in the background processing system.
Unless session is processed, the data is not transferred to database table.
BDC_OPEN_GROUP
You create the session through program by BDC_OPEN_GROUP function.
Parameters to this function are:
User Name: User name
Group: Name of the session
Lock Date: The date on which you want to process the session.
Keep: This parameter is passed as X when you want to retain session after
processing it or to delete it after processing.
BDC_INSERT
This function creates the session & data is transferred to Session.
Parameters to this function are:
Tcode: Transaction Name
Dynprotab: BDC Data
BDC_CLOSE_GROUP
This function closes the BDC Group. No Parameters.
Some additional information for session processing
When the session is generated using the KEEP option within the BDC_OPEN_GROUP, the system always keeps the sessions in the queue, whether it has been processed successfully or not.
However, if the session is processed, you have to delete it manually. When session processing is completed successfully while KEEP option was not set, it will be removed automatically from the session queue. Log is not removed for that session.
If the batch-input session is terminated with errors, then it appears in the list of INCORRECT session and it can be processed again. To correct incorrect session, you can analyze the session. The Analysis function allows to determine which screen and value has produced the error. If you find small errors in data, you can correct them interactively, otherwise you need to modify batch input program, which has generated the session or many times even the data file.
CALL TRANSACTION
About CALL TRANSACTION
A technique similar to SESSION method, while batch input is a two-step procedure, Call Transaction does both steps online, one after the other. In this method, you call a transaction from your program by
Call transaction <tcode> using <BDCTAB>
Mode <A/N/E>
Update <S/A>
Messages into <MSGTAB>.
Parameter 1 is transaction code.
Parameter 2 is name of BDCTAB table.
Parameter 3 here you are specifying mode in which you execute transaction
A is all screen mode. All the screen of transaction are displayed.
N is no screen mode. No screen is displayed when you execute the transaction.
E is error screen. Only those screens are displayed wherein you have error record.
Parameter 4 here you are specifying update type by which database table is updated.
S is for Synchronous update in which if you change data of one table then all the related Tables gets updated. And sy-subrc is returned i.e., sy-subrc is returned for once and all.
A is for Asynchronous update. When you change data of one table, the sy-subrc is returned. And then updating of other affected tables takes place. So if system fails to update other tables, still sy-subrc returned is 0 (i.e., when first table gets updated).
Parameter 5 when you update database table, operation is either successful or unsuccessful or operation is successful with some warning. These messages are stored in internal table, which you specify along with MESSAGE statement. This internal table should be declared like BDCMSGCOLL, a structure available in ABAP/4. It contains the following fields:
1. Tcode: Transaction code
2. Dyname: Batch point module name
3. Dynumb: Batch input Dyn number
4. Msgtyp: Batch input message type (A/E/W/I/S)
5. Msgspra: Batch input Lang, id of message
6. Msgid: Message id
7. MsgvN: Message variables (N = 1 - 4)
For each entry, which is updated in database, table message is available in BDCMSGCOLL. As BDCMSGCOLL is structure, you need to declare a internal table which can contain multiple records (unlike structure).
Steps for CALL TRANSACTION method
1. Internal table for the data (structure similar to your local file)
2. BDCTAB like BDCDATA
3. UPLOAD or WS_UPLOAD function to upload the data from local file to itab. (Considering file is local file)
4. Loop at itab.
Populate BDCTAB table.
Call transaction <tcode> using <BDCTAB>
Mode <A/N/E>
Update <S/A>.
Refresh BDCTAB.
Endloop.
(To populate BDCTAB, You need to transfer each and every field)
The major differences between Session method and Call transaction are as follows:
SESSION METHOD CALL TRANSACTION
1. Data is not updated in database table unless Session is processed. Immediate updation in database table.
2. No sy-subrc is returned. Sy-subrc is returned.
3. Error log is created for error records. Errors need to be handled explicitly
4. Updation in database table is always synchronous Updation in database table can be synchronous Or Asynchronous.
Error Handling in CALL TRANSACTION
When Session Method updates the records in database table, error records are stored in the log file. In Call transaction there is no such log file available and error record is lost unless handled. Usually you need to give report of all the error records i.e., records which are not inserted or updated in the database table. This can be done by the following method:
Steps for the error handling in CALL TRANSACTION
1. Internal table for the data (structure similar to your local file)
2. BDCTAB like BDCDATA
3. Internal table BDCMSG like BDCMSGCOLL
4. Internal table similar to Ist internal table
(Third and fourth steps are for error handling)
5. UPLOAD or WS_UPLOAD function to upload the data from the local file to itab. (Considering file is local file)
6. Loop at itab.
Populate BDCTAB table.
Call transaction <tr.code> using <Bdctab>
Mode <A/N/E>
Update <S/A>
Messages <BDCMSG>.
Perform check.
Refresh BDCTAB.
Endloop.
7 Form check.
IF sy-subrc <> 0. (Call transaction returns the sy-subrc if updating is not successful).
Call function Format_message.
(This function is called to store the message given by system and to display it along with record)
Append itab2.
Display the record and message.
Check this program for session method using multiple transactions.
Have one BDC_OPEN_GROUP, multiple BDC_INSERT s and one BDC_CLOSE_GROUP.
You should have multiple BDC_INSERT s for multiple transactions.
call function BDC_OPENGROUP.
Build BDC data and cal lBDC_INSERT for transaction 1
Build BDC data and cal lBDC_INSERT for transaction 2
Build BDC data and cal lBDC_INSERT for transaction 3
call function BDC_CLOSE_GROUP.
Check out this sample program
REPORT ztest_report
NO STANDARD PAGE HEADING
LINE-SIZE 255
MESSAGE-ID ZRASH.
Internal Table Declarations *
*--Internal Table for Data Uploading.
DATA : BEGIN OF IT_FFCUST OCCURS 0,
KUNNR(10),
BUKRS(4),
KTOKD(4),
ANRED(15),
NAME1(35),
SORTL(10),
STRAS(35),
ORT01(35),
PSTLZ(10),
LAND1(3),
SPRAS(2),
AKONT(10),
END OF IT_FFCUST.
*--Internal Table to Store Error Records.
DATA : BEGIN OF IT_ERRCUST OCCURS 0,
KUNNR(10),
EMSG(255),
END OF IT_ERRCUST.
*--Internal Table to Store Successful Records.
DATA : BEGIN OF IT_SUCCUST OCCURS 0,
KUNNR(10),
SMSG(255),
END OF IT_SUCCUST.
*--Internal Table for Storing the BDC data.
DATA : IT_CUSTBDC LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*--Internal Table for storing the messages.
DATA : IT_CUSTMSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : V_FLAG1(1) VALUE ' ',
"Flag used for opening session.
V_TLINES LIKE SY-TABIX,
"For storing total records processed.
V_ELINES LIKE SY-TABIX,
"For storing the no of error records.
V_SLINES LIKE SY-TABIX.
"For storing the no of success records.
Selection screen *
SELECTION-SCREEN BEGIN OF BLOCK B1.
PARAMETERS : V_FNAME LIKE RLGRAP-FILENAME,
V_SESNAM LIKE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B1.
Start-of-selection *
START-OF-SELECTION.
*-- Form to upload flatfile data into the internal table.
PERFORM FORM_UPLOADFF.
TOP-OF-PAGE *
TOP-OF-PAGE.
WRITE:/ 'Details of the error and success records for the transaction'
ULINE.
SKIP.
End of Selection *
END-OF-SELECTION.
*-- Form to Generate a BDC from the Uploaded Internal table
PERFORM FORM_BDCGENERATE.
*--To write the totals and the session name.
PERFORM FORM_WRITEOP.
*& Form form_uploadff
Form to upload flatfile data into the internal table.
FORM FORM_UPLOADFF .
*--Variable to change the type of the parameter file name.
DATA : LV_FILE TYPE STRING.
LV_FILE = V_FNAME.
*--Function to upload the flat file to the internal table.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = LV_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = IT_FFCUST
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
IF SY-SUBRC = 0.
*--Deleting the headings from the internal table.
DELETE IT_FFCUST INDEX 1.
*--Getting the total number of records uploaded.
DESCRIBE TABLE IT_FFCUST LINES V_TLINES.
ENDIF.
ENDFORM. " form_uploadff
*& Form Form_bdcgenerate
Form to Generate a BDC from the Uploaded Internal table
FORM FORM_BDCGENERATE .
*--Generating the BDC table for the fields of the internal table.
LOOP AT IT_FFCUST.
PERFORM POPULATEBDC USING :
'X' 'SAPMF02D' '0105',
' ' 'BDC_OKCODE' '/00' ,
' ' 'RF02D-KUNNR' IT_FFCUST-KUNNR,
' ' 'RF02D-BUKRS' IT_FFCUST-BUKRS,
' ' 'RF02D-KTOKD' IT_FFCUST-KTOKD,
'X' 'SAPMF02D' '0110' ,
' ' 'BDC_OKCODE' '/00',
' ' 'KNA1-ANRED' IT_FFCUST-ANRED,
' ' 'KNA1-NAME1' IT_FFCUST-NAME1,
' ' 'KNA1-SORTL' IT_FFCUST-SORTL,
' ' 'KNA1-STRAS' IT_FFCUST-STRAS,
' ' 'KNA1-ORT01' IT_FFCUST-ORT01,
' ' 'KNA1-PSTLZ' IT_FFCUST-PSTLZ,
' ' 'KNA1-LAND1' IT_FFCUST-LAND1,
' ' 'KNA1-SPRAS' IT_FFCUST-SPRAS,
'X' 'SAPMFO2D' '0120',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0125',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0130',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0340',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0360',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0210',
' ' 'KNB1-AKONT' IT_FFCUST-AKONT,
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0215',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0220',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0230',
' ' 'BDC_OKCODE' '=UPDA'.
*--Calling the transaction 'fd01'.
CALL TRANSACTION 'FD01' USING IT_CUSTBDC MODE 'N' UPDATE 'S'
MESSAGES INTO IT_CUSTMSG.
IF SY-SUBRC <> 0.
*--Populating the error records internal table.
IT_ERRCUST-KUNNR = IT_FFCUST-KUNNR.
APPEND IT_ERRCUST.
CLEAR IT_ERRCUST.
*--Opening a session if there is an error record.
IF V_FLAG1 = ' '.
PERFORM FORM_OPENSESSION.
V_FLAG1 = 'X'.
ENDIF.
*--Inserting the error records into already open session.
IF V_FLAG1 = 'X'.
PERFORM FORM_INSERT.
ENDIF.
*--Populating the Success records internal table.
ELSE.
IT_SUCCUST-KUNNR = IT_FFCUST-KUNNR.
APPEND IT_SUCCUST.
CLEAR IT_SUCCUST.
ENDIF.
*--Displaying the messages.
IF NOT IT_CUSTMSG[] IS INITIAL.
PERFORM FORM_FORMATMSG.
ENDIF.
*--Clearing the message and bdc tables.
CLEAR : IT_CUSTBDC[],IT_CUSTMSG[].
ENDLOOP.
*--Getting the total no of error records.
DESCRIBE TABLE IT_ERRCUST LINES V_ELINES.
*--Getting the total no of successful records.
DESCRIBE TABLE IT_SUCCUST LINES V_SLINES.
*--Closing the session only if it is open.
IF V_FLAG1 = 'X'.
PERFORM FORM_CLOSESESS.
ENDIF.
ENDFORM. " Form_bdcgenerate
*& Form populatebdc
FOrm to Populate the BDC table.
FORM POPULATEBDC USING VALUE(P_0178)
VALUE(P_0179)
VALUE(P_0180).
IF P_0178 = 'X'.
IT_CUSTBDC-PROGRAM = P_0179.
IT_CUSTBDC-DYNPRO = P_0180.
IT_CUSTBDC-DYNBEGIN = 'X'.
ELSE.
IT_CUSTBDC-FNAM = P_0179.
IT_CUSTBDC-FVAL = P_0180.
ENDIF.
APPEND IT_CUSTBDC.
CLEAR IT_CUSTBDC.
ENDFORM. " populatebdc
*& Form FORM_OPENSESSION
Form to Open a session.
FORM FORM_OPENSESSION .
*--Variable to convert the given session name into reqd type.
DATA : LV_SESNAM(12).
LV_SESNAM = V_SESNAM.
*--Opening a session.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = LV_SESNAM
HOLDDATE = '20040805'
KEEP = 'X'
USER = SY-UNAME
PROG = SY-CPROG
IMPORTING
QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
IF SY-SUBRC <> 0.
WRITE :/ 'Session not open'.
ENDIF.
ENDFORM. " FORM_OPENSESSION
*& Form FORM_INSERT
fORM TO INSERT ERROR RECOED INTO A SESSION.
FORM FORM_INSERT .
*--Inserting the record into session.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'FD01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
DYNPROTAB = IT_CUSTBDC
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
IF SY-SUBRC <> 0.
WRITE :/ 'Unable to insert the record'.
ENDIF.
ENDFORM. " FORM_INSERT
*& Form FORM_CLOSESESS
Form to Close the Open Session.
FORM FORM_CLOSESESS .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. " FORM_CLOSESESS
*& Form FORM_FORMATMSG
Form to format messages.
FORM FORM_FORMATMSG .
*--Var to store the formatted msg.
DATA : LV_MSG(255).
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = SY-LANGU
NO = SY-MSGNO
V1 = SY-MSGV1
V2 = SY-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = LV_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE :/ LV_MSG.
ENDIF.
ULINE.
ENDFORM. " FORM_FORMATMSG
*& Form form_writeop
To write the totals and the session name.
FORM FORM_WRITEOP .
WRITE :/ 'Total Records Uploaded :',V_TLINES,
/ 'No of Error Records :',V_ELINES,
/ 'No of Success Records :',V_SLINES,
/ 'Name of the Session :',V_SESNAM.
ULINE.
ENDFORM. " form_writeop
Hope this resolves your query.
Reward all the helpful answers.
Regards -
Hello Friends,
Can you guide me how to create BDC with SESSION method.?
Please mantion examples.
Thanks in advance.
Regards,
nimesh masterSee below example code :
Call three FM : BDC_OPEN_GROUP,BDC_INSERT and BDC_CLOSE_GROUP.
Once you execute the program and it creates the session at SM35 Transaction.
Report : ZMPPC011
Type : Data upload
Author : Chetan Shah
Date : 05/05/2005
Transport : DV3K919557
Transaction: ??
Description: This ABAP/4 Program creates new Production Versions
(C223). It accepts tab-delimited spreadsheet input and
creates BDC sessions.
Modification Log
Date Programmer Request # Description
06/10/2005 Chetan Shah DV3K919557 Initial coding
report zmppc011 no standard page heading line-size 120 line-count 55
message-id zz.
pool of form routines
include zmppn001.
Define BDC Table Structure
data: begin of itab_bdc_tab occurs 0.
include structure bdcdata.
data: end of itab_bdc_tab.
Input record layout of Leagcy File
data: begin of itab_xcel occurs 0,
matnr(18) type c,
werks(4) type c,
alnag(2) type c,
verid(4) type c,
text1(40) type c,
bstmi like mkal-bstmi,
bstma like mkal-bstma,
adatu(10) type c,
bdatu(10) type c,
stlal(2) type c,
stlan(1) type c,
serkz(1) type c,
mdv01(8) type c,
elpro(4) type c,
alort(4) type c,
end of itab_xcel.
data: begin of lt_pp04_cache occurs 0,
matnr like itab_xcel-matnr,
werks like itab_xcel-werks,
alnag like itab_xcel-alnag,
plnnr like mapl-plnnr,
arbpl like crhd-arbpl,
ktext like crtx-ktext,
end of lt_pp04_cache.
data: v_ssnnr(4) type n,
v_lines_in_xcel like sy-tabix,
v_ssnname like apqi-groupid,
v_trans_in_ssn type i,
wa_xcel LIKE itab_xcel,
l_tabix like sy-tabix,
v_matnr like rc27m-matnr,
v_plnnr like mapl-plnnr,
v_plnal like mapl-plnal,
v_tcode like sy-tcode value 'C223',
v_plnty like plas-plnty value 'R',
v_objty like crhd-objty value 'A',
v_plpo_steus like plpo-steus value 'PP04',
v_verwe like crhd-verwe value '0007'.
Parameters
selection-screen: skip 3.
selection-screen: begin of block 1 with frame.
parameters: p_name like rlgrap-filename
default 'C:\My Documents\InputFile.txt'
obligatory,
bdc session name prefix
p_bdcpfx(6) default 'ZPVCRT'
obligatory,
number for transction per BDC session
p_trnssn type i
default 2000 obligatory,
retain the BDC session after successfull execution
p_keep like apqi-qerase
default 'X',
user who will be executing BDC session
p_uname like apqi-userid
default sy-uname
obligatory.
selection-screen: end of block 1.
possible entry list (F4 dropdown) for input file name
at selection-screen on value-request for p_name.
*-SELECT FILE FROM USERS LOCAL PC
call function 'WS_FILENAME_GET'
exporting
DEF_FILENAME = ' '
def_path = 'C:\Temp\'
mask = ',.,..'
mode = 'O'
title = 'Select File '(007)
importing
filename = p_name
RC =
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 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.
endif.
begin the show
start-of-selection.
read data from input file
perform transfer_xcel_to_itab.
loop at itab_xcel.
hang on to xcel line num
l_tabix = sy-tabix.
each line in the xcel file marks begining of new prod.version defn
if num-of-trnas-in-session = 0, create new BDC session
if v_trans_in_ssn is initial.
perform bdc_session_open.
endif.
begin new bdc script for rtg create trans
fill in bdc-data for prod.version maintenance screens
perform bdc_build_script.
insert the bdc script as a BDC transaction
perform bdc_submit_transaction.
keep track of how many BDC transactions were inserted in the BDC
session
add 1 to v_trans_in_ssn.
if the user-specified num of trans in BDC session is reached OR
if end of input file is reached, close the BDC session
if v_trans_in_ssn = p_trnssn or
l_tabix = v_lines_in_xcel.
perform bdc_session_close.
clear v_trans_in_ssn.
endif.
endloop.
top-of-page.
call function 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
FORM TRANSFER_XCEL_TO_ITAB *
Transfer Xcel Spreadsheet to SAP Internal Table *
form transfer_xcel_to_itab.
Read the tab-delimited file into itab
call function 'WS_UPLOAD'
exporting
filename = p_name
filetype = 'DAT'
IMPORTING
filelength = flength
tables
data_tab = itab_xcel
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
others = 8.
if sy-subrc = 0.
sort the data
sort itab_xcel by matnr werks.
clear v_lines_in_xcel.
if no data in the file - error out
describe table itab_xcel lines v_lines_in_xcel.
if v_lines_in_xcel is initial.
write: / 'No data in input file'.
stop.
endif.
else.
if file upload failed - error out
write: / 'Error reading input file'.
stop.
endif.
endform.
FORM BDC_SESSION_OPEN *
Open BDC Session *
form bdc_session_open.
create bdc session name = prefix-from-selectn-screen + nnnn
add 1 to v_ssnnr.
concatenate p_bdcpfx v_ssnnr into v_ssnname.
open new bdc session
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
group = v_ssnname
keep = p_keep
user = p_uname
exceptions
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 10
others = 11.
endform.
FORM BDC_BUILD_SCRIPT *
Build BDC *
form bdc_build_script.
data: l_arbpl like crhd-arbpl,
l_text1 like mkal-text1,
l_mdv01 like mkal-mdv01,
l_mapl like mapl.
clear bdc-data itab - begin of new bdc transaction
clear itab_bdc_tab.
refresh itab_bdc_tab.
read material cross reference tables to determine sap part#
clear : v_matnr, v_plnnr, v_plnal.
perform read_matnr_cross_ref using itab_xcel-matnr
itab_xcel-werks
changing v_matnr.
determine the version description to use
if itab_xcel-text1 is initial.
l_text1 = itab_xcel-verid.
else.
l_text1 = itab_xcel-text1.
endif.
determine the routing group# and group ctr# to use
perform read_routing .
determine the production line to use
if itab_xcel-mdv01 is initial.
if not provided in the file then:
prod line = work ctr on the last PP04 op of the rtg determined above
perform read_wc_on_last_pp04 using v_plnnr v_plnal
changing l_mdv01.
NOTE: when executing the above form\routine, if v_plnnr is initial
or v_plnal is initial, THEN l_mdv01 will automatically be
returned blank (ie initial)
else.
l_mdv01 = itab_xcel-mdv01.
endif.
build bdc script
perform bdc_build_script_record
fill in initial screen
using: 'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=ENTE',
' ' 'MKAL-WERKS' itab_xcel-werks,
' ' 'MKAL-MATNR' v_matnr,
' ' 'MKAL_ADMIN-DISPO' space,
' ' 'MKAL-PLNNR' space,
' ' 'MKAL_ADMIN-STTAG' space,
' ' 'MKAL-PLNNG' space,
' ' 'MKAL-MDV01' space,
' ' 'MKAL-PLNNM' space,
click create button on initial screen and go to detail screen
'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=CREA',
fill in the detail screen and go back to initial screen
'X' 'SAPLCMFV' '2000',
' ' 'BDC_OKCODE' '=CLOS',
' ' 'MKAL_EXPAND-MATNR' v_matnr,
' ' 'MKAL_EXPAND-VERID' itab_xcel-verid,
' ' 'MKAL_EXPAND-TEXT1' l_text1,
' ' 'MKAL_EXPAND-BSTMI' itab_xcel-bstmi,
' ' 'MKAL_EXPAND-BSTMA' itab_xcel-bstma,
' ' 'MKAL_EXPAND-ADATU' itab_xcel-adatu,
' ' 'MKAL_EXPAND-BDATU' itab_xcel-bdatu,
' ' 'MKAL_EXPAND-PLTYG' v_plnty,
' ' 'MKAL_EXPAND-PLNNG' v_plnnr,
' ' 'MKAL_EXPAND-ALNAG' v_plnal,
' ' 'MKAL_EXPAND-STLAL' itab_xcel-stlal,
' ' 'MKAL_EXPAND-STLAN' itab_xcel-stlan,
' ' 'MKAL_EXPAND-SERKZ' itab_xcel-serkz,
' ' 'MKAL_EXPAND-MDV01' l_mdv01,
' ' 'MKAL_EXPAND-ELPRO' itab_xcel-elpro,
' ' 'MKAL_EXPAND-ALORT' itab_xcel-alort,
save the production version from initial screen
'X' 'SAPLCMFV' '1000',
' ' 'BDC_OKCODE' '=SAVE'.
endform.
FORM BDC_SUBMIT_TRANSACTION *
Submit BDC Session *
form bdc_submit_transaction.
Load BDC script as a trqansction in BDC session
call function 'BDC_INSERT'
exporting
tcode = v_tcode
tables
dynprotab = itab_bdc_tab
exceptions
internal_error = 01
not_open = 02
queue_error = 03
tcode_invalid = 04.
endform.
FORM BDC_BUILD_SCRIPT_RECORD *
form bdc_build_script_record using dynbegin name value.
clear itab_bdc_tab.
if dynbegin = 'X'.
move: name to itab_bdc_tab-program,
value to itab_bdc_tab-dynpro,
'X' to itab_bdc_tab-dynbegin.
else.
move: name to itab_bdc_tab-fnam,
value to itab_bdc_tab-fval.
shift itab_bdc_tab-fval left deleting leading space.
endif.
append itab_bdc_tab.
endform.
FORM BDC_SESSION_CLOSE *
Close BDC Session *
form bdc_session_close.
close the session
call function 'BDC_CLOSE_GROUP'
exceptions
not_open = 1
queue_error = 2
others = 3.
skip 2.
if sy-subrc ne 0.
write: / 'Error Closing BDC Session ' , 'RETURN CODE: ', sy-subrc.
else.
write : / 'Session created:', v_ssnname,
50 '# of transactions:', v_trans_in_ssn.
endif.
endform.
*& Form read_routing_cache
*FORM read_routing_cache USING pi_matnr
pi_werks
pi_alnag
pi_verid
pi_mdv01.
DATA: BEGIN OF lt_plpo OCCURS 0,
vornr LIKE plpo-vornr,
objty LIKE crhd-objty,
objid LIKE crhd-objid,
arbpl LIKE crhd-arbpl,
END OF lt_plpo,
l_mapl_plnnr LIKE mapl-plnnr.
determine the routing group#
CLEAR lt_pp04_cache.
chk if its in the cache first, if not then get it from MAPL table
and put it in the cache
READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
IF sy-subrc = 0.
do nothing - lt_pp04_cache header line has rtg#
ELSE.
get the routing group # from MAPL
SELECT plnnr INTO l_mapl_plnnr
FROM mapl UP TO 1 ROWS
WHERE matnr = pi_matnr AND
werks = pi_werks AND
plnty = 'R' AND
plnal = pi_alnag AND
loekz = space.
ENDSELECT.
put it in the cache internal table
IF NOT l_mapl_plnnr IS INITIAL.
lt_pp04_cache-matnr = pi_matnr.
lt_pp04_cache-werks = pi_werks.
lt_pp04_cache-alnag = pi_alnag.
lt_pp04_cache-plnnr = l_mapl_plnnr.
APPEND lt_pp04_cache.
ENDIF.
ENDIF.
if the rtg# was determined AND
-- the work center was not determined yet AND
-- work center was really needed for this line in the input file
then
-- read the work center from last PP04 operation on the routing
-- update the cache accordingly
IF NOT lt_pp04_cache-plnnr IS INITIAL AND
lt_pp04_cache-arbpl IS INITIAL AND
( pi_verid IS INITIAL OR
pi_mdv01 IS INITIAL ).
read the last PP04 operation
CLEAR lt_plpo.
REFRESH lt_plpo.
SELECT vornr eobjty eobjid e~arbpl
INTO CORRESPONDING FIELDS OF TABLE lt_plpo
FROM plas AS b
INNER JOIN plpo AS c
ON bplnty = cplnty AND
bplnnr = cplnnr AND
bzaehl = czaehl
INNER JOIN crhd AS e
ON carbid = eobjid
WHERE b~plnty = v_plnty AND
b~plnnr = lt_pp04_cache-plnnr AND
b~plnal = lt_pp04_cache-alnag AND
c~loekz = space AND
c~steus = v_plpo_steus AND
e~objty = v_objty AND
e~werks = lt_pp04_cache-werks AND
e~verwe = v_verwe.
SORT lt_plpo BY vornr DESCENDING.
READ TABLE lt_plpo INDEX 1.
IF NOT lt_plpo-arbpl IS INITIAL.
lt_pp04_cache-arbpl = lt_plpo-arbpl.
read work center description
SELECT SINGLE ktext INTO lt_pp04_cache-ktext
FROM crtx WHERE objty = lt_plpo-objty AND
objid = lt_plpo-objid AND
spras = sy-langu.
the following read will get the index of the correct record to be
updated in the cache
READ TABLE lt_pp04_cache
WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
MODIFY lt_pp04_cache
INDEX sy-tabix
TRANSPORTING arbpl ktext.
ENDIF.
ENDIF.
*ENDFORM. " read_last_pp04_operation_cache
*& Form read_routing
form read_routing.
data: begin of lt_mapl occurs 0,
plnnr like mapl-plnnr,
plnal like mapl-plnal,
end of lt_mapl,
l_arbpl like crhd-arbpl.
get all the rtg# and grp ctr# from MAPL
select plnnr plnal
into corresponding fields of table lt_mapl
from mapl
where matnr = v_matnr and
werks = itab_xcel-werks and
plnty = v_plnty and "Rate Routing
loekz = space. "with del flag = OFF
sort lt_mapl by plnal.
if not itab_xcel-verid is initial.
if the verid=0001 then use the 1st good rtg-grp# and grp-ctr#
if itab_xcel-verid = '0001'.
read table lt_mapl index 1.
v_plnnr = lt_mapl-plnnr.
v_plnal = lt_mapl-plnal.
else.
if the verid<>0001 then use the rtg-grp# and grp-ctr# of the routing
whose work center on the last PP04 operation matches the given verid
loop at lt_mapl.
clear l_arbpl.
get the work center from the last PP04 operation
perform read_wc_on_last_pp04 using lt_mapl-plnnr
lt_mapl-plnal
changing l_arbpl.
if itab_xcel-verid = l_arbpl.
v_plnnr = lt_mapl-plnnr.
v_plnal = lt_mapl-plnal.
exit.
endif.
endloop.
endif.
else.
do nothing
endif.
For version IDs that are other then '0000' or 'ZWIP' :--
if itab_xcel-verid NE '0000' and
itab_xcel-verid NE 'ZWIP'.
if routing group# or group counter was not determined, make the
valid-to date 99/99/9999 so that the BDC, on execution, errors out.
if v_plnnr is initial or
v_plnal is initial.
itab_xcel-bdatu = '99/99/9999'.
endif.
endif.
determine the routing group#
CLEAR lt_pp04_cache.
chk if its in the cache first, if not then get it from MAPL table
and put it in the cache
READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
IF sy-subrc = 0.
do nothing - lt_pp04_cache header line has rtg#
ELSE.
get the routing group # from MAPL
put it in the cache internal table
IF NOT l_mapl_plnnr IS INITIAL.
lt_pp04_cache-matnr = pi_matnr.
lt_pp04_cache-werks = pi_werks.
lt_pp04_cache-alnag = pi_alnag.
lt_pp04_cache-plnnr = l_mapl_plnnr.
APPEND lt_pp04_cache.
ENDIF.
ENDIF.
if the rtg# was determined AND
-- the work center was not determined yet AND
-- work center was really needed for this line in the input file
then
-- read the work center from last PP04 operation on the routing
-- update the cache accordingly
IF NOT lt_pp04_cache-plnnr IS INITIAL AND
lt_pp04_cache-arbpl IS INITIAL AND
( pi_verid IS INITIAL OR
pi_mdv01 IS INITIAL ).
read the last PP04 operation
CLEAR lt_plpo.
REFRESH lt_plpo.
SELECT vornr eobjty eobjid e~arbpl
INTO CORRESPONDING FIELDS OF TABLE lt_plpo
FROM plas AS b
INNER JOIN plpo AS c
ON bplnty = cplnty AND
bplnnr = cplnnr AND
bzaehl = czaehl
INNER JOIN crhd AS e
ON carbid = eobjid
WHERE b~plnty = v_plnty AND
b~plnnr = lt_pp04_cache-plnnr AND
b~plnal = lt_pp04_cache-alnag AND
c~loekz = space AND
c~steus = v_plpo_steus AND
e~objty = v_objty AND
e~werks = lt_pp04_cache-werks AND
e~verwe = v_verwe.
SORT lt_plpo BY vornr DESCENDING.
READ TABLE lt_plpo INDEX 1.
IF NOT lt_plpo-arbpl IS INITIAL.
lt_pp04_cache-arbpl = lt_plpo-arbpl.
read work center description
SELECT SINGLE ktext INTO lt_pp04_cache-ktext
FROM crtx WHERE objty = lt_plpo-objty AND
objid = lt_plpo-objid AND
spras = sy-langu.
the following read will get the index of the correct record to be
updated in the cache
READ TABLE lt_pp04_cache
WITH KEY matnr = pi_matnr
werks = pi_werks
alnag = pi_alnag.
MODIFY lt_pp04_cache
INDEX sy-tabix
TRANSPORTING arbpl ktext.
ENDIF.
ENDIF.
endform. " read_last_pp04_operation_cache
*& Form read_wc_on_last_pp04
form read_wc_on_last_pp04 using pi_plnnr
pi_plnal
changing pe_arbpl.
data: begin of lt_plpo occurs 0,
vornr like plpo-vornr,
objty like crhd-objty,
objid like crhd-objid,
arbpl like crhd-arbpl,
end of lt_plpo.
get all the PP04 operations for the given rtg# & grp-ctr#
select vornr eobjty eobjid e~arbpl
into corresponding fields of table lt_plpo
from plas as b
inner join plpo as c
on bplnty = cplnty and
bplnnr = cplnnr and
bzaehl = czaehl
inner join crhd as e
on carbid = eobjid
where b~plnty = v_plnty and "Rate Routing
b~plnnr = pi_plnnr and
b~plnal = pi_plnal and
c~loekz = space and "Oper Del Flag = OFF
c~steus = v_plpo_steus and "PP04
e~objty = v_objty. "WC Obj Type = 'A'
read the last operation
sort lt_plpo by vornr descending.
read table lt_plpo index 1.
pe_arbpl = lt_plpo-arbpl.
endform. " read_wc_on_last_pp04
Reward Points if it is useful
Thanks
Seshu
Maybe you are looking for
-
Distiller error when trying to save book as pdf
I haven't used FrameMaker since about version 5 or 6, but recently I have picked up a few client jobs requiring RoboHelp and FrameMaker. I tearfully parted with the funds for TS 4, crossing my fingers that the investment would pay itself off. I have
-
Hi, I just switched from a windows notebook to an iBook. How do I set a password for opening and modifying a Pages document as you do in Word? Thanks.
-
I've down loaded the new version according to Creative Cloud but when I try to launch the app the window appears saying there is a new version, so I click on download now and it crashes. What's happening and what should I do? Thanks.
-
Footer extends longer in Preview Mode then in Design Mode
I have attached two JPEGS that show my footer in "Design" mode and in "Preview" mode. In "Design" mode the footer is perfect. It is the size and distance it needs to be at. However, when viewing it in "Preview Mode", the footer extends downward fa
-
Can't Play AVI files (revisited)
I have installed both the DivX and Perian bundles and I am still get the white frame in QuickTime when I try to play an AVI file. Does anyone have any solutions on how to get AVI files to play in QuickTime? My workflow is this... I have created uncom