BPM BAPI COMMIT
Hi,
I try to create a sync connection BPM which soap post data to BPM then inside BPM i have 2 bapi which the first bapi will need to commit by XI before process the second bapi. I have done all this and it work but there was a problem of the commit process time sometime the second bapi will return mat doc not found. I know that BPM have the wait process but the minimum time is 1 minute which is quit long for sync process. Is that any way to make the second bapi process only is the 1st bapi commit successful.
Best Regard,
Gan
Hi,
Thanks for reply. I am also consider about the performance of the BPM but the reason i am using BPM is to let the XI handle the commit for bapi. For example lets said after XI past data to bapi and then the connection between XI and SAP R3 down then the soap client cant get the data but the bapi with commit if i put the commit on z bapi. In order to control this i have to let XI control the commit.
Is that anyway to handle this?
Best Regard,
GAN
Edited by: fcgan on Dec 2, 2008 8:12 AM
Similar Messages
-
Hi everybody!
In my scenario I post an RFC call to a BAPI (BAPI_GOODSMVT_CREATE). The call succeeds (empty RETURN parameter, material document numer is returned). However, the resulting material document is not available in MB03 - I assume this is due to a missing COMMIT after the RFC call.
However, our system has SP 18 - and I have read that the RFC adapter is able to add a COMMIT after a successful call automatically starting from SP 14. What confuses me is the fact that the descriptions in the online sources state that I should check the "Extended Mode" checkbox in the RFC adapter config screen and then I should check the "Commit..." option. However, when I set the checkbox for extended parameters, I only get a simple table where I can enter property/value pairs.
Has something gone wrong with the upgrade and my RFC adapter doesn't have SP 18 yet? Or am I doing something wrong?
Regards, JoergHi Joerg,
Check in your Repository if you imported the newest adapter metadata.
Check Software Component SAP BASIS - > SAP BASIS 6.40 -> http://sap.com/xi/XI/System
There Adapterobjects -> Adaptermetadata -> RFC
search after the attribute ..<b>singelBapiCommit</b>
Because you dont see a SP version there.
Maybe its better to search afer the label:
<b>Commit handling for singel BAPI-calls</b>
When you dont find the attribute .. try to reimport your BASIS 6.40 Software Componenent.
Regards,
Robin -
BAPI commit without using Wait? need to get the data for created order
I am using BAPI to create or change sales order and by using 'BAPI_TRANSACTION_COMMIT' updating the database.
Immediately after that there is some requirement to fetch VBAP with the created order number, but there is no data found.
If i use call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
then i am able to fetch data from VBAP, but its impacting the performance. Is there any alternative way to get data without fetching or without using wait.
Can i use ABAP memory or SAP memory to get the details?
Please help...........Hi Tapas379,
Yes technically you can:
set data before commit
DATA memory_id(20) TYPE c.
CONCATENATE 'VBAP_01_' sy-uname INTO memory_id.
DELETE FROM DATABASE indx(as) ID memory_id.
EXPORT vbap_tab = vbap_tab "<-input
TO DATABASE indx(as)
CLIENT sy-mandt
ID memory_id.
Get data from anywhere after setting it.
data memory_id(20) type c.
concatenate 'VBAP_01_' sy-uname into memory_id.
import vbap_tab = vbap_tab " ->output
from database indx(as)
client sy-mandt
id memory_id.
delete from database indx(as) id memory_id.
Thanks,
Duy -
WebService From a BAPI & Commit
Heyho!
I created a Webservice from a BAPI (From BusinessPartner, to create a BP).
There is the option to add "TransactionCommit" and "TransactionRollBack" to the Service Definition (that is what i did).
I consume the Webservice with an external Java-Application, create a BP and then call the commit.
My Problem is that the BP can't be found anymore as if it wasn't even created.
The counter for the BPs did counter++ but there is no BP to be shown.
Anyone?
regards
frankThank you all for your replies,
i solved this problem with the following:
1)
i created a new RFC-able FM
2)
I Called the BAPI-Method
3)
I Called 'BAPI_COMMIT_TRANSACTION'
4)
I generated the Webservice
thank you
frank -
Explicit BAPI Commit in Inbound FM
I want to commit a BAPI BAPI_GOODSMVT_CREATE , which I will use in an implicit enhancement in FM IDOC_INPUT_INVOIC_MRM.
This FM is called during Inbound IDOC incoming.
I want to commit this BAPI BAPI_GOODSMVT_CREATE before IDOC is posted. So if I create a wrapper FM for this BAPI and call that in update task ...will the BAPI get commited before IDOC is posted if I set in se37->Attributes Tab -> Update Module ->Start Immed.
Any answers will be highly appreciated.
Thanks
Please refer to thread
Inbound IDOC commit
for similar question.Check if this works for u.
BAPI_HU_PACK -
Dear All,
I have been working with an assignment and facing a strange issue.
I have used the 'BAPI_SALESORDER_CHANGE' to modify sales order and then I call 'BAPI_TRANSACTION_COMMIT' with wait = X. So, this bapi modifies the sales order schedule lines and also in turn updates the info structure linked to it (In our case, say it is S800)
Immediately after this I have a select statement on S800 to fetch the records.
On debug, if I break at select statement, I get correct records from S800 but If i break one step after select it gives me different records.
I think there is some delay in updation of infostructure, hence, If i use wait statement before select for 1 sec, it works fine, but cause performance issues.
for over 15000 order items, it will wait for around 8 hours, hence, i would like to know is there any way I can avoid wait and also read the infostructure for correct records.
<< Moderator message - Everyone's problem is important. Please do not ask for help quickly. >>
Edited by: Rob Burbank on Feb 24, 2011 9:45 PMHi Chandanrs,
with COMMIT WORK (or BAPI_TRANSACTION_COMMIT) with WAIT addition, processing is continued after all high-priority ("VB1") update function modules are executed in the order of their registration and in a shared database LUW.
That means that the info structures are probably updated in low-priority ("VB2") update.
I never faced this situation but I think that the info structure should still be locked. Try to find the corresponding lock object, in a (test) run, locks may be visible shortly in SM12 lock overview.
If possible, after commit work, try to call the enqueue function with the same arguments as it is done within the BAPI processing. You should get a foreign lock error until the end of the second level update process.
while lv_locked is initial.
call function 'ENQUEUE...
IF sy-subrc = 0.
lv_locked = 'X'.
endif.
endwhile.
call function 'DEQUEUE...
clear lv_locked.
This lets your program wait until the info structure update is complete. Sorry I do not really know which lock object is used here. Anyway, I still do not know why you have to read the S900 directly after update.
You may also process all orders to the to set the order quantity to delivered qty, COMMIT every 1000 or so orders, put the original quantity to internal table. Then do the same for restoring.
BAPI processes run a great deal faster if you do not COMMIT after every single document. But you can't take too many because than you risk a lock table overflow.
Hope it is some help anyway.
Regards,
Clemens -
Hi,
A scenario File - BPM - BAPI call was developed, as described in blog 'RFC scenario using BPM' cfr. link
/people/arpit.seth/blog/2005/06/27/rfc-scenario-using-bpm--starter-kit
The Mapping is as follows:
MT_EDB_MATERIAL_REQ (1:1) --> BAPI_MATERIAL_EXISTENCE_CHECK (1:1)
MATNR (1:1) -
> MATERIAL (1:1)
When executing the scenario, an error appears in the trace of SXMB_MONI, step 'Request Message Mapping'
Cannot produce target element /ns1:BAPI_MATERIAL_EXISTENCECHECK. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd....
I tried the following:
1) import the XML-file into the testmapping: executed successfully
File:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_EDB_MATERIAL_REQ xmlns:ns0="http://agfa.com/SD_EDB">
<MATNR>15P6X</MATNR>
</ns0:MT_EDB_MATERIAL_REQ>
2) Removed the mapping on node level and left mapping only on element level (material): same error
3) Activated the message mapping, interface mapping, determinations, etc again...:same error
4) Removed the Interface Mapping and created it again: same error
5) Compared the version ID of the Interface Mapping/message mapping in the Monitor trace with the version ID of the IR and saw that there was a difference.
After the CPA full cache, SXI_CACHE full refresh and object refresh in the IB Administration, the differences remain, and also the error....
Anybody an idea ?Hi
>>>Cannot produce target element /ns1:BAPI_MATERIAL_EXISTENCECHECK. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd....
The error clearly says that one of the occurrence value for the target node mentioned is not coming from the source during mapping. The easiest way to solve the problem is as follows
<b>
First Execute the mapping as pointed out by "Raj" and the following steps.
</b>
1. Goto the Mapping Editor
2. Double click on the target node that is causing the problem here BAPI_MATERIAL_EXISTENCECHECK.
3. Right click on the same node and select "DisplayQueue".
4. View the Queue.
5. YOu will find "Suppress" entries, which means a value is expected but no value is coming in.
6.Go from right to left and check each node in the mapping and you will be able to trace where the suppress node comes from and take appropriate action
regards
krishna -
Web Service Commit (BAPI inside out)
Hi all,
I want to use update BAPI through web service which made by Web Service Wizard.
I know we usually have to use BAPI_TRANSACTION_COMMIT to commit.
Can I call single web service with commit?
I found optional configrations in Service Definision (TR- SE80).
"Configration" Tab=>"Operation Profile".
commit hundling
tranaction hudling
It seems we can commit without BAPI_TRANSACTION_COMMIT.
I tried several options but it didn't work.
And I could find any document in help.sap.com and SDN like
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/9b/dad1ae3908ee44a5caf57e10918be9/frameset.htm
Requirement
1) We want to use BAPI without rapping.
2) We want to use Web Service Wizard for BAPI/RFC web service generation.
Environment
ERP6.0 NW7.0(SP18)
Regards,
TeruTeru,
When the web service is made for the BAPI to update, through the wizard,
1) the endpoint should be selected as BAPI after giving the service name and short text
2) Next scree, choose the application and the BAPI you need for update
3) On the next screen, you have the option to add BAPI commit function to the existing list of methods. There is a pushbutoon which appears at the bottom of the table - BAPI Commit/Rollback
So, the we service will have the BAPI commit included along with the update BAPI. So you need to invoke only one webservice from your end.
Hope this helps!!
Regards
Deepthi -
Dear Experts
In a RFC, our codes are as follows:
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
MODIFY Ztable FROM TABLE it_ztable.
COMMIT WORK.
We wonder to know that how do we pack above actions into a LUW for the consistency of commit or rollback.Hi Custodio de Oliveira
I have followed your suggestion and written sample codes to create sales order.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = lt_order_header
TABLES
return = lt_return
order_items_in = lt_order_item
order_partners = lt_order_partner
order_schedules_in = lt_order_schdl.
READ TABLE lt_return WITH KEY TYPE = 'S'
ID = 'V1'
NUMBER = '311'.
IF SY-SUBRC EQ 0.
MODIFY ZT_PROG_MSG FROM TABLE lt_msg.
IF SY-SUBRC EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = lt_return2.
ELSE.
IF SY-SUBRC NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ENDIF.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
And I manually adjust duplication number range for causing an update error.
In debug mode, I check the return type in "lt_return", and then I can get 'S'.
However, after BAPI_TRANSACTION_COMMIT, there is update error for sales order creation, but our Ztable(ZT_PROG_MSG)is still updated successfully. How can we assure consistency, if there is any system error making bapi commit failure? -
Creation of purchase order using bapi
hi gurus,
Can anyone give me an example of how to create purchase order using bapiHi use BAPI_PO_CREATE.. I have an eg. of changing a PO using BAPI. This is almost similar to create.. Go thru and let me know if u need more info..
Dont forget to use 'BAPI COMMIT' after the function call...
DATA:
*Update Short text, qty, net price, item no.,
*agreement no. and agreement line no.
it_po_item TYPE TABLE OF bapimepoitem,
*Select fields
it_po_item_x TYPE TABLE OF bapimepoitemx,
*Delivery date
it_po_schedule TYPE TABLE OF bapimeposchedule,
*Select fields
it_po_schedule_x TYPE TABLE OF bapimeposchedulx,
*Return parameters
it_return TYPE TABLE OF bapiret2,
*PO Account
it_po_account TYPE TABLE OF bapimepoaccount,
*Select fields
it_po_account_x TYPE TABLE OF bapimepoaccountx,
Condition Types
it_po_cond TYPE TABLE OF bapimepocond,
*Select fields
it_po_cond_x TYPE TABLE OF bapimepocondx,
it_po_text type table of BAPIMEPOTEXT.
Structures
DATA:
st_po_header TYPE bapimepoheader,
st_po_header_x TYPE bapimepoheaderx,
st_po_item LIKE LINE OF it_po_item,
st_po_item_x LIKE LINE OF it_po_item_x,
st_po_schedule LIKE LINE OF it_po_schedule,
st_po_schedule_x LIKE LINE OF it_po_schedule_x,
st_return TYPE bapiret2,
st_po_account LIKE LINE OF it_po_account,
st_po_account_x LIKE LINE OF it_po_account_x,
st_po_cond LIKE LINE OF it_po_cond,
st_po_cond_x LIKE LINE OF it_po_cond_x,
st_po_text like line of it_po_text.
Variables
DATA : po_number TYPE bapimepoheader-po_number,
w_item_no(10) TYPE n VALUE '1'.
START-OF-SELECTION.
test values
po_number = '94490'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = po_number
IMPORTING
OUTPUT = po_number
st_po_item-po_item = w_item_no.
st_po_item-quantity = '00.000'.
st_po_item-delete_ind = 'X'.
st_po_item-short_text = 'ZMU-test1'.
st_po_item-agreement = '0060000128'.
st_po_item-agmt_item = '1'.
st_po_item-net_price = '1'.
st_po_item_x-po_item = w_item_no.
st_po_item_x-po_itemx = 'X'.
st_po_item_x-delete_ind = 'X'.
st_po_item_x-quantity = 'X'.
st_po_item_x-short_text = 'X'.
st_po_item_x-agreement = 'X'.
st_po_item_x-agmt_item = 'X'.
st_po_item_x-net_price = 'X'.
st_po_schedule-po_item = w_item_no.
st_po_schedule-delivery_date = '9/19/2008'.
st_po_schedule-quantity = '1'.
st_po_schedule_x-po_item = w_item_no.
st_po_schedule_x-po_itemx = 'X'.
st_po_schedule_x-delivery_date = 'X'.
st_po_schedule_x-quantity = 'X'.
st_po_cond-itm_number = w_item_no.
st_po_cond-cond_type = 'PB00'.
st_po_cond-cond_value = '1.000'.
st_po_cond-currency = 'USD'.
st_po_cond-change_id = 'U'.
st_po_cond_x-itm_number = w_item_no.
st_po_cond_x-itm_numberx = 'X'.
st_po_cond_x-cond_type = 'X'.
st_po_cond_x-cond_value = 'X'.
st_po_cond_x-currency = 'X'.
st_po_cond_x-change_id = 'X'.
st_po_text-PO_NUMBER = po_number.
st_po_text-PO_ITEM = w_item_no.
st_po_text-TEXT_LINE = 'MU_TEST1 MU_TEST2'.
APPEND:
st_po_item_x TO it_po_item_x,
st_po_item TO it_po_item.
st_po_schedule_x TO it_po_schedule_x,
st_po_schedule TO it_po_schedule,
st_po_cond TO it_po_cond,
st_po_cond_x TO it_po_cond_x,
st_po_text to it_po_text.
st_po_text-PO_NUMBER = po_number.
st_po_text-PO_ITEM = w_item_no.
st_po_text-TEXT_LINE = 'MU_TEST2'.
st_po_text-TEXT_FORM = '03'.
append st_po_text to it_po_text.
PERFORM function_call.
LOOP AT it_return INTO st_return.
WRITE:/ st_return-message, 'Message type =', st_return-type,/.
ENDLOOP.
REFRESH:
it_return,
it_po_item,
it_po_item_x,
it_po_cond,
it_po_cond_x.
PERFORM update_price.
WRITE:/ 'After update - Messages'.
LOOP AT it_return INTO st_return.
WRITE:/ st_return-message, 'Message type =', st_return-type,/.
ENDLOOP.
data: begin of test occurs 0,
f1,
end of test.
FORM function_call *
FORM function_call.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = po_number
POHEADER =
POHEADERX =
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
IMPORTING
EXPHEADER =
TABLES
return = it_return
poitem = it_po_item
poitemx = it_po_item_x
POADDRDELIVERY =
poschedule = it_po_schedule
poschedulex = it_po_schedule_x
poaccount =
POACCOUNTPROFITSEGMENT =
poaccountx =
POCONDHEADER =
POCONDHEADERX =
pocond = it_po_cond
pocondx = it_po_cond_x
POLIMITS =
POCONTRACTLIMITS =
POSERVICES =
POSRVACCESSVALUES =
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POTEXTHEADER =
POTEXTITEM = it_po_text
POPARTNER =
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = st_return.
ENDFORM. -
Problem in uploading multiple line items while Creating sales order by BAPI
Hi experts , Im able to create sales order with one item while using this program, but the problem is when iam having multiple items or multiple sales order , iam not able to createthe line items , though its creating sales order header , Iam copy pasting my code , please add the additional code to my code to take more than 1 line items ,This is urgent requirement . Points will be rewarded for answers , Thanks in advance
*& Report Z_SO_CREATE_BAPI
REPORT Z_SO_CREATE_BAPI.
DATA: i_header TYPE bapisdhd1 occurs 0 with header line.
DATA: i_details TYPE bapisditm OCCURS 0 WITH HEADER LINE.
DATA: i_partner TYPE bapiparnr OCCURS 0 WITH HEADER LINE.
DATA: i_return1 TYPE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: i_return2 TYPE bapiret2.
data : ORDER_HEADER_IN like BAPISDHD1.
data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with HEADER LINE .
data : ORDER_ITEMS_INX Like BAPISDITMX occurs 0 with HEADER LINE .
data : RETURN like BAPIRET2 occurs 0 with header line.
data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
header line.
DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
LiNE.
data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
header line.
data : ORDER_SCHEDULES_INX like BAPISCHDLX occurs 0 with
header line.
data : BEGIN OF TAB OCCURS 0,
SRNO(4),
DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
DIVISION like ORDER_HEADER_IN-DIVISION,
REQ_DATE_H(10),
PURCH_DATE(10),
PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
ITM_NUMBER like BAPISDITM-ITM_NUMBER,
MATERIAL LIKE ORDER_ITEMS_IN-MATERIAL ,
PLANT LIKE ORDER_ITEMS_IN-PLANT,
TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
ITM_NUMBERX like ORDER_ITEMS_INX-ITM_NUMBER ,
MATERIALX LIKE ORDER_ITEMS_INX-MATERIAL ,
CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
PLANTX LIKE ORDER_ITEMS_INX-PLANT,
TARGET_QTYX LIKE ORDER_ITEMS_INX-TARGET_QTY,
ITM_NUMBER LIKE ORDER_ITEMS_IN-ITM_NUMBER,
MATERIAL LIKE ORDER_ITEMS_IN-MATERIAL ,
PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
END OF TAB.
DATA: v_vbeln TYPE bapivbeln-vbeln.
selection-screen begin of block b1 with frame.
skip 3.
parameter:p_infile like rlgrap-filename obligatory.
skip 3.
selection-screen end of block b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
PERFORM value_help.
start-of-selection.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = p_infile
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = tab.
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**Validation for the Create SO screen
*AT SELECTION-SCREEN ON BLOCK na_create.
Loop at Tab.
i_header-doc_type = TAB-DOC_TYPE .
i_header-sales_org = TAB-SALES_ORG.
i_header-distr_chan = TAB-DISTR_CHAN .
i_header-division = TAB-DIVISION .
append i_header.
*endloop.
i_partner-partn_role = TAB-PARTN_ROLE .
i_partner-partn_numb = TAB-PARTN_NUMB.
APPEND i_partner.
i_details-material = TAB-MATERIAL .
APPEND i_details.
endloop.
*Bapi for Creating SO
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN = v_vbeln
order_header_in = i_header
ORDER_HEADER_INX =
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
SALESDOCUMENT = v_vbeln
tables
RETURN = i_return1
ORDER_ITEMS_IN = i_details
ORDER_ITEMS_INX = ORDER_ITEMS_INX
order_partners = i_partner .
ORDER_SCHEDULES_IN =
ORDER_SCHEDULES_INX =
ORDER_CONDITIONS_IN =
ORDER_CONDITIONS_INX =
ORDER_CFGS_REF =
ORDER_CFGS_INST =
ORDER_CFGS_PART_OF =
ORDER_CFGS_VALUE =
ORDER_CFGS_BLOB =
ORDER_CFGS_VK =
ORDER_CFGS_REFINST =
ORDER_CCARD =
ORDER_TEXT =
ORDER_KEYS =
EXTENSIONIN =
PARTNERADDRESSES =
IF NOT v_vbeln IS INITIAL.
*Bapi Commit Work
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
return = i_return2
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
IMPORTING
RETURN =
ENDIF.
LOOP AT i_return1 . "INTO wa_return1.
WRITE:/ i_return1-message.
ENDLOOP.
FORM value_help .
CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
EXPORTING
DEF_FILENAME = ' '
DEF_PATH = ' '
MASK = ',.,..'
MODE = 'O'
TITLE = ' '
IMPORTING
FILENAME = p_infile
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.
endform.
txt file data
order type salesorg distch divison materialno parter role
TA PB01 01 00 000000000000000852 WE
Partner no
8101000000Hi Neerja,
you can reffer this sample code. It may not be complet soluation for your poblem,
but you will get some idea.
*& Report ZBAPI_SALESORDER_CREATE
*& Author : Karthik
REPORT ZBAPI_SALESORDER_CREATE.
data : ORDER_HEADER_IN like BAPISDHD1.
data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with
header line.
data : RETURN like BAPIRET2 occurs 0 with header line.
data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
header line.
DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
LINE.
data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
header line.
data : BEGIN OF TAB OCCURS 0,
SRNO(4),
DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
DIVISION like ORDER_HEADER_IN-DIVISION,
REQ_DATE_H(10),
PURCH_DATE(10),
PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
ITM_NUMBER like BAPISDITM-ITM_NUMBER,
CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
PLANT LIKE ORDER_ITEMS_IN-PLANT,
TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
END OF TAB.
data: itab1 like alsmex_tabline occurs 0 with header
line.
DATA: gd_currentrow type i.
data : PURCHASEORDER like ekko-ebeln.
Data: tot_rec type i, "Total Records
gd_update type i, "Main Table Increement Counter
gd_lines type i, "Success Table increement Counter
w_textout like t100-text. "VARIABLE TO GET ERRORLOG
data : begin of it_success occurs 0,
SALESDOCUMENT LIKE BAPIVBELN-VBELN, "PROJECT
end of it_success.
data : begin of it_error occurs 0,
srno(4),
err_msg(73) TYPE c, "TO RETREIVE ERROR MESSAGES
end of it_error.
data : srno(4).
DATA : SALESDOCUMENT LIKE BAPIVBELN-VBELN.
selection-screen begin of block b1 with frame.
skip 3.
parameter:p_infile like rlgrap-filename obligatory.
skip 3.
selection-screen end of block b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
PERFORM value_help.
start-of-selection.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_infile
i_begin_col = '1'
i_begin_row = '2' "Do not require
headings
i_end_col = '22'
i_end_row = '10000'
TABLES
intern = itab1
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message e010(zz) with text-001. "Problem uploading
Excel Spreadsheet
endif.
*perform open_group.
sort itab1 by row col.
Get first row retrieved
read table itab1 index 1.
Set first row retrieved to current row
gd_currentrow = itab1-row.
loop at itab1.
Reset values for next row
if itab1-row ne gd_currentrow.
append tab .
clear tab.
gd_currentrow = itab1-row.
endif.
SHIFT ITAB1-VALUE LEFT DELETING LEADING SPACE.
case itab1-col.
when '0001'.
TAB-SRNO = itab1-value.
when '0002'.
TAB-DOC_TYPE = itab1-value.
when '0003'.
TAB-SALES_ORG = itab1-value.
when '0004'.
TAB-DISTR_CHAN = itab1-value.
when '0005'.
TAB-DIVISION = itab1-value.
when '0006'.
TAB-REQ_DATE_H = itab1-value.
when '0006'.
TAB-PURCH_DATE = itab1-value.
when '0007'.
TAB-PMNTTRMS = itab1-value.
when '0008'.
TAB-PURCH_NO_C = itab1-value.
when '0009'.
TAB-ITM_NUMBER = itab1-value.
when '0010'.
TAB-CUST_MAT22 = itab1-value.
when '0011'.
TAB-PLANT = itab1-value.
when '0012'.
TAB-TARGET_QTY = itab1-value.
when '0013'.
TAB-PARTN_ROLE = itab1-value.
when '0014'.
TAB-PARTN_NUMB = itab1-value.
endcase.
endloop.
append tab.
clear tab.
sort tab by SRNO.
LOOP AT TAB.
concatenate tab-REQ_DATE_H+4(4)
tab-REQ_DATE_H2(2) tab-REQ_DATE_H0(2) into
tab-REQ_DATE_H.
concatenate tab-PURCH_DATE+4(4)
tab-PURCH_DATE2(2) tab-PURCH_DATE0(2) into
tab-PURCH_DATE.
SRNO = TAB-SRNO.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = tab-PARTN_NUMB
IMPORTING
OUTPUT = tab-PARTN_NUMB.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = tab-CUST_MAT22
IMPORTING
OUTPUT = tab-CUST_MAT22.
IF TAB-SRNO = SRNO.
ORDER_HEADER_IN-DOC_TYPE = TAB-DOC_TYPE.
ORDER_HEADER_IN-SALES_ORG = TAB-SALES_ORG.
ORDER_HEADER_IN-DISTR_CHAN = TAB-DISTR_CHAN.
ORDER_HEADER_IN-REQ_DATE_H = TAB-REQ_DATE_H.
ORDER_HEADER_IN-PURCH_DATE = TAB-PURCH_DATE.
ORDER_HEADER_IN-PMNTTRMS = TAB-PMNTTRMS.
ORDER_HEADER_IN-PURCH_NO_C = TAB-PURCH_NO_C.
ORDER_HEADER_IN-DIVISION = tab-DIVISION.
ORDER_ITEMS_IN-ITM_NUMBER = tab-ITM_NUMBER.
ORDER_ITEMS_IN-material = TAB-CUST_MAT22.
ORDER_ITEMS_IN-PLANT = TAB-PLANT.
APPEND ORDER_ITEMS_IN.
ORDER_PARTNERS-PARTN_ROLE = TAB-PARTN_ROLE.
ORDER_PARTNERS-PARTN_NUMB = TAB-PARTN_NUMB.
APPEND ORDER_PARTNERS.
ORDER_SCHEDULES_IN-ITM_NUMBER = tab-ITM_NUMBER.
ORDER_SCHEDULES_IN-REQ_QTY = tab-TARGET_QTY.
append ORDER_SCHEDULES_IN.
ENDIF.
AT END OF SRNO.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN =
ORDER_HEADER_IN = ORDER_HEADER_IN
ORDER_HEADER_INX =
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
SALESDOCUMENT = SALESDOCUMENT
TABLES
RETURN = RETURN
ORDER_ITEMS_IN = ORDER_ITEMS_IN
ORDER_ITEMS_INX =
ORDER_PARTNERS = ORDER_PARTNERS
ORDER_SCHEDULES_IN = ORDER_SCHEDULES_IN
ORDER_SCHEDULES_INX =
ORDER_CONDITIONS_IN =
ORDER_CONDITIONS_INX =
ORDER_CFGS_REF =
ORDER_CFGS_INST =
ORDER_CFGS_PART_OF =
ORDER_CFGS_VALUE =
ORDER_CFGS_BLOB =
ORDER_CFGS_VK =
ORDER_CFGS_REFINST =
ORDER_CCARD =
ORDER_TEXT =
ORDER_KEYS = ORDER_KEYS
EXTENSIONIN =
PARTNERADDRESSES =
IF SALESDOCUMENT <> SPACE.
commit work.
ADD 1 TO gd_update.
it_success-SALESDOCUMENT = SALESDOCUMENT.
append it_success.
CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
ELSE.
loop at return.
it_error-SRNO = tab-SRNO.
it_error-err_msg = return-MESSAGE .
Append it_error.
ENDLOOP.
CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
ENDIF.
endat.
endloop.
DESCRIBE TABLE it_success LINES gd_lines.
IF gd_lines GT 0.
Display result report column headings
PERFORM display_column_headings.
Display result report
PERFORM DISPLAY_SUCESS.
ENDIF.
IF SUCESS FAILS Display Error Report
DESCRIBE TABLE it_error LINES gd_lines.
IF gd_lines GT 0.
PERFORM errorheadings.
PERFORM errorreport.
ENDIF.
*& Form display_column_headings
text
FORM display_column_headings.
WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
SKIP.
WRITE:2 'The following records inserted
successfully:'(013).
WRITE:/ sy-uline(15).
FORMAT COLOR COL_HEADING.
WRITE:/ sy-vline,
(10) 'Sales order'(004), sy-vline.
WRITE:/ sy-uline(15).
ENDFORM. "display_column_headings
*Subroutine to display SUCESS REPORT
FORM DISPLAY_SUCESS.
FORMAT COLOR COL_NORMAL.
LOOP AT it_success.
WRITE:/ sy-vline,
(10) it_success-SALESDOCUMENT, sy-vline.
CLEAR it_success.
ENDLOOP.
WRITE:/ sy-uline(15).
REFRESH: it_success.
FORMAT COLOR COL_BACKGROUND.
ENDFORM. "
DISPLAY_REPORT
*& Form errorreport
text
FORM errorreport.
LOOP AT it_error.
WRITE:/ sy-vline,
(10) it_error-SRNO, sy-vline,
(40) it_error-err_msg, sy-vline.
ENDLOOP.
WRITE:/ sy-uline(104).
REFRESH: it_error.
endform. "errorreport
*& Form ERRORHEADINGS
text
FORM ERRORHEADINGS.
SKIP.
WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
SKIP.
WRITE:2 'The following records failed during
update:'(008).
WRITE:/ sy-uline(104).
FORMAT COLOR COL_HEADING.
WRITE:/ sy-vline,
(10) 'ERROR.'(009), sy-vline.
WRITE:/ sy-uline(104).
FORMAT COLOR COL_NORMAL.
ENDFORM. "ERRORHEADINGS
**& Form value_help
text
--> p1 text
<-- p2 text
FORM value_help .
CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
EXPORTING
DEF_FILENAME = ' '
DEF_PATH = ' '
MASK = ',.,..'
MODE = 'O'
TITLE = ' '
IMPORTING
FILENAME = p_infile
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.
endform. "value_help
Regards,
Amit. -
Transaction VA01 separate LUW / commit DB when creating in Background PO
Hi experts,
I have a request to create a PO for a particular item of a sales document, and for the PO created I need to fill one component and to lock it. I found out that the only way to create for sure a PO is the FM BAPI_ORDER_CREATE. To update the components and to lock it I need a BDC. I did not found any FM which might do something like this.
The place where I trigger the creation of PO is user_exit_save_document. My logic is the following: I create the PO with BAPI_ORDER_CREATE in another LUW then trigger commit both with BAPI commit and commit work for this separate LUW, In the same LUW in which I created the PO, after the commit, I call a BDC Function Module that updates the component and locks the PO.
I observed that the BAPI ORDER CREATE works fine - it always creates me a PO. When running in the next step the BDC FM , it always returns me the message "PO (before created) does not exist". In debug Mode everything works fine, PO is created and also BDC FM does not return me any error.
It seems to me that when the logic runs in dialog mode all the PO tables are not updated before I run the BDC. As I am openning a separate LUW and I trigger explicitly COMMIT in this separate LUW I was wondering why does not the update of PO tables take place? Is this because the transaction VA01 does not allow any commits for the programms that are called from the transaction? Or what am I missing?
I did a kind of workaround and I don#t run the BDC only after the batch input is created, but I was wondering why am I wrong.
Thank you for the support,
FlorinHi
I suppose the problem is the time taken to run the saving process, this process is still running while your BDC is starting.
U should use a COMMIT WORK and WAIT in order to be sure the saving process is over before calling the BDC.
Now I don't understand where you have place the COMMIT for the BAPI
Max
P.S.: BAPI ORDER CREATE doesn't exist in my systen, I have BAPI_PO_CREATE1
Max
Edited by: max bianchi on Aug 15, 2011 1:40 PM -
Dump while creating sales order using BAPI
Hi Experts,
I am trying to create a sales order in my alv report using BAPI_SALESORDER_CREATEFROMDAT2. I get a dump while executing the program. Please suggest me where I am going wrong.
|Source Code Extract |
|Line |SourceCde |
| 1|FORM FRM_KOND_BASIS_604. |
| 2|*{ INSERT DEVK910738 1 |
| 3| |
| 4|data: zuomqtyo LIKE ekpo-menge, |
| 5| zuomqtyn LIKE ekpo-menge, |
| 6| zqty1 type i, |
| 7| zqty2(11) type n. |
| 8| |
| 9|** Round up billing qty |
| 10| if komp-zzLTKZA ne 'VAR'. |
| 11| |
|>>>>>| zqty1 = xkwert. |
| 13| compute zqty2 = zqty1 / 1000. |
| 14| xkwert = zqty2 * 1000. |
| 15| |
| 16| exit. |
| 17| endif. |
| 18| |
| 19| |
| 20|** Samples |
| 21| |
| 22| if komp-MATKL = '5400'. |
| 23| |
| 24| check not xkomv-kmein is initial. |
| 25| check not komp-vrkme is initial. |
| 26| |
| 27|** Make sure base is correct when sales unit and pricing unit differ |
| 28| if komp-vrkme ne xkomv-kmein. |
| 29| |
| 30| zuomqtyo = komp-MGAME. |
| 31| |
Thanks.John,
Here is what I am doing.
*Assign Header Data And Move To Header Data Final Table
GS_ORDERHEADERIN-DOC_TYPE = GC_AUART.
GS_ORDERHEADERIN-SALES_ORG = GC_SORG.
GS_ORDERHEADERIN-DISTR_CHAN = GC_DISTC.
GS_ORDERHEADERIN-DIVISION = GC_DIVI.
GS_ORDERHEADERIN-ORD_REASON = GC_AUGRU.
GS_ORDERHEADERIN-REQ_DATE_H = WA-USAGE_DATE.
GS_ORDERHEADERIN-PURCH_DATE = WA-USAGE_DATE.
GS_ORDERHEADERIN-PURCH_NO_C = WA-USAGE_DOC.
*Assign Header Data And Move To Header Data Final Table
GS_ORDERHEADERINX-DOC_TYPE = GC_FLAG.
GS_ORDERHEADERINX-SALES_ORG = GC_FLAG.
GS_ORDERHEADERINX-DISTR_CHAN = GC_FLAG.
GS_ORDERHEADERINX-DIVISION = GC_FLAG.
GS_ORDERHEADERINX-ORD_REASON = GC_FLAG.
GS_ORDERHEADERINX-REQ_DATE_H = GC_FLAG.
GS_ORDERHEADERINX-PURCH_DATE = GC_FLAG.
GS_ORDERHEADERINX-PURCH_NO_C = GC_FLAG.
*ASSIGN ITEMS DATA AND MOVE TO ITEMS DATA FINAL TABLE
GS_ORDERITEMSIN-ITM_NUMBER = WA-POSNR.
GS_ORDERITEMSIN-MATERIAL = WA-MATERIAL.
GS_ORDERITEMSIN-TARGET_QTY = WA-EXT_QTY. "EXT_QTY is of type LFIMG
GS_ORDERITEMSIN-TARGET_QU = WA-EXT_UOM. "EXT_UOM is of type VRKME
APPEND GS_ORDERITEMSIN TO GT_ORDERITEMSIN.
CLEAR GS_ORDERITEMSIN.
*Assign Items Data And Move To Items Data Final Table
GS_ORDERITEMSINX-ITM_NUMBER = WA-POSNR.
GS_ORDERITEMSINX-MATERIAL = GC_FLAG.
GS_ORDERITEMSINX-TARGET_QTY = GC_FLAG.
GS_ORDERITEMSINX-TARGET_QU = GC_FLAG.
APPEND GS_ORDERITEMSINX TO GT_ORDERITEMSINX.
CLEAR GS_ORDERITEMSINX.
*Assign Schedule Lines Data And Move To Schedule Lines Final Table
GS_ORDER_SCHEDULES_IN-ITM_NUMBER = WA-POSNR.
GS_ORDER_SCHEDULES_IN-REQ_DATE = WA-USAGE_DATE.
GS_ORDER_SCHEDULES_IN-REQ_QTY = WA-EXT_QTY. "EXT_QTY is of type LFIMG
APPEND GS_ORDER_SCHEDULES_IN TO GT_ORDER_SCHEDULES_IN.
CLEAR GS_ORDER_SCHEDULES_IN.
*Assign Schedule Lines Data And Move To Schedule Lines Final Table
GS_ORDER_SCHEDULES_INX-ITM_NUMBER = WA-POSNR.
GS_ORDER_SCHEDULES_INX-REQ_DATE = GC_FLAG.
GS_ORDER_SCHEDULES_INX-REQ_QTY = GC_FLAG.
APPEND GS_ORDER_SCHEDULES_INX TO GT_ORDER_SCHEDULES_INX.
CLEAR GS_ORDER_SCHEDULES_INX.
*Assign Sold-To-Partner Data And Move To Final Partners Table
GS_ORDERPARTNERS-PARTN_ROLE = GC_SP.
GS_ORDERPARTNERS-PARTN_NUMB = GV_SOLD.
APPEND GS_ORDERPARTNERS TO GT_ORDERPARTNERS.
CLEAR GS_ORDERPARTNERS.
*Assign Ship-To-Partner Data And Move To Partners Table
GS_ORDERPARTNERS-PARTN_ROLE = GC_SH.
GS_ORDERPARTNERS-PARTN_NUMB = GV_SHIP.
APPEND GS_ORDERPARTNERS TO GT_ORDERPARTNERS.
CLEAR GS_ORDERPARTNERS.
*Clear Global Variable Field Of Sales Document
CLEAR:GV_SALESDOCUMENT.
"Right after pressing F6 button after this. It gives me dump.
*Call Function Module To Create Sales Order
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = GS_ORDERHEADERIN
ORDER_HEADER_INX = GS_ORDERHEADERINX
IMPORTING
SALESDOCUMENT = GV_SALESDOCUMENT
TABLES
ORDER_ITEMS_IN = GT_ORDERITEMSIN
ORDER_ITEMS_INX = GT_ORDERITEMSINX
ORDER_SCHEDULES_IN = GT_ORDER_SCHEDULES_IN
ORDER_SCHEDULES_INX = GT_ORDER_SCHEDULES_INX
ORDER_PARTNERS = GT_ORDERPARTNERS
RETURN = GT_BAPIRETURN.
IF SY-SUBRC = 0.
*Call Function Module For BAPI Commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = GC_FLAG.
ENDIF.
All my BAPI tables have been filled with required data in them. But, still it is giving me a dump.
I would really appreciate if some one could suggest me where I am going wrong.
Thanks. -
Bapi goods movement Create (User Locking Error)
HI all ,
Please help me in the issue . I am doing Goods movement through BAPI(BAPI_GOODSMOVEMENT_CREATE) and i am scheduling this job in background . I am gettigng an Error of Plant data of Material locked by the user(myself) and for the next iteration its not proceeded . Please help me how to get rid of the error .
Thanks in advance,Hi Eric,
Is the value get updated in the table? After the Goods movement BAPI Just do wait up to 5 seconds and do the bapi commit.
Other wise if it is possible just debug .
With Regards,
Sumodh.P -
Hi guys,
I'm doing an RFC scenario and publishing it as a java proxy. The BAPI i'm using here is BAPI_CHARACT_CREATE.
The scenario is working fine, but when i have executed the Create BAPI with some value, I'm not seeing that Value to be updated in the characteristics data given by Transaction "CT04"
I'm not an ABAPer, So if any1 can get me out of this, It'll be really helpful...
Thanks Guys
VarunYou are using the "Commit Handling for single bapi calls" in the adapter?
BAPI commit handling: The RFC adapter supports a single BAPI call including a commit in order to release a transaction and process the BAPI return table
Maybe you are looking for
-
Exception while Exporting Datagridview data with Images to Excel...
Hi Everyone, I have datagridview in that 17 columns are text columns and 5 columns are Image columns,when I'm trying to export whole gridview data's along with images to EXCEL,getting "HRESULT: 0x800A03EC" Error..While debugging the code I'm getting
-
Verizon now forcing new contracts instead of month to month
My FIOS bundle expired in March. I understood both from online statements and from talking with Verizon support that my services would continue on a month to month basis. I was happy with this while I look at whether I will continue with FIOS, purcha
-
Hello All, I have an example which use simulated signal with its web service generated by LabVIEW. Then an application of this web service was created using NI web UI builder. And application was build and deployed on NI Cloud Portal,
-
i had an AMD system. now i have a P4 with HT. at hardware list (properties) i see 2 P4 processors. is that hyper treading? also at task manager (ctrl+alt+del) at the tab performance i see 2 cpu health meters. is that correct??
-
Startup Macbook in Closed Display Mode
Hi everyone. I'm using my macbook with an external big display, keyboard and mouse. I recently discovered I could close the cover of my macbook and use the external as the main display. The thing is that I hate having to open the mac each time I want