cancel
Showing results for 
Search instead for 
Did you mean: 

Need help on using createfromdata1 to create PO

Former Member
0 Kudos

Hi guys,

I went thru the examples which came with Nco2.0 and there isn't any trasaction examples such like creating SOs or POs. Can anyone kindly provide me some useful code samples or tutorials of how to create POs which simply contains PoHeader and PoItem. thanks.

from a Nco/Bapi rookie

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

After all,

nothing big deal acctually, just create "all" of the required instances and variables and dump them into the function module, that's it.

the working code as the following

//////////////////////////////////

DTP_PO.BAPIMEPOHEADER poHeader = new BAPIMEPOHEADER();

DTP_PO.BAPIMEPOHEADERX poHeaderX = new BAPIMEPOHEADERX();

DTP_PO.BAPIMEPOITEM poItem = new BAPIMEPOITEM();

DTP_PO.BAPIMEPOITEMTable poItemTable = new BAPIMEPOITEMTable();

DTP_PO.BAPIMEPOITEMX poItemX = new BAPIMEPOITEMX();

DTP_PO.BAPIMEPOITEMXTable poItemXTable = new BAPIMEPOITEMXTable();

DTP_PO.BAPIMEPOSCHEDULE poSch = new BAPIMEPOSCHEDULE();

DTP_PO.BAPIMEPOSCHEDULETable poSchTable = new BAPIMEPOSCHEDULETable();

DTP_PO.BAPIMEPOSCHEDULX poSchX = new BAPIMEPOSCHEDULX();

DTP_PO.BAPIMEPOSCHEDULXTable poSchXTable = new BAPIMEPOSCHEDULXTable();

string expPO = "";

DTP_PO.BAPIMEPOHEADER expHeader = new BAPIMEPOHEADER();

DTP_PO.BAPIEIKP expeikp = new BAPIEIKP();

DTP_PO.BAPIEIKP eikp = new BAPIEIKP();

DTP_PO.BAPIEIKPX eikpx = new BAPIEIKPX();

DTP_PO.BAPIMEPOADDRVENDOR addrv = new BAPIMEPOADDRVENDOR();

DTP_PO.BAPIESUCCTable esucc = new BAPIESUCCTable();

DTP_PO.BAPIEIPOTable eipo = new BAPIEIPOTable();

DTP_PO.BAPIEIPOXTable eipox = new BAPIEIPOXTable();

DTP_PO.BAPIEKKOPTable ekkop = new BAPIEKKOPTable();

DTP_PO.BAPIESKLCTable esklc = new BAPIESKLCTable();

DTP_PO.BAPIESLLCTable esllc = new BAPIESLLCTable();

DTP_PO.BAPIESLLTXTable eslltx = new BAPIESLLTXTable();

DTP_PO.BAPIESUHCTable esuhc = new BAPIESUHCTable();

DTP_PO.BAPIMEDCM_ALLVERSIONSTable allversions = new BAPIMEDCM_ALLVERSIONSTable();

DTP_PO.BAPIMEPOACCOUNTPROFITSEGMENTTable accountp = new BAPIMEPOACCOUNTPROFITSEGMENTTable();

DTP_PO.BAPIMEPOACCOUNTTable account = new BAPIMEPOACCOUNTTable();

DTP_PO.BAPIMEPOACCOUNTXTable accountx = new BAPIMEPOACCOUNTXTable();

DTP_PO.BAPIMEPOADDRDELIVERYTable addrd = new BAPIMEPOADDRDELIVERYTable();

DTP_PO.BAPIMEPOCONDHEADERTable condheader = new BAPIMEPOCONDHEADERTable();

DTP_PO.BAPIMEPOCONDHEADERXTable condheaderx = new BAPIMEPOCONDHEADERXTable();

DTP_PO.BAPIMEPOCONDTable cond = new BAPIMEPOCONDTable();

DTP_PO.BAPIMEPOCONDXTable condx = new BAPIMEPOCONDXTable();

DTP_PO.BAPIMEPOTEXTHEADERTable texthead = new BAPIMEPOTEXTHEADERTable();

DTP_PO.BAPIMEPOTEXTTable text = new BAPIMEPOTEXTTable();

DTP_PO.BAPIPAREXTable parexin = new BAPIPAREXTable();

DTP_PO.BAPIPAREXTable parexout = new BAPIPAREXTable();

DTP_PO.BAPIRET2Table ret2 = new BAPIRET2Table();

DTP_PO.BAPIMEDCM dcm = new BAPIMEDCM();

poHeader.Doc_Type = "NB";

poHeader.Vendor = "0000010002";

poHeader.Doc_Date = "20050413";

poHeader.Comp_Code = "PS01";

poHeader.Pmnttrms = "A035";

//poHeader.Currency = "TWD";

poHeader.Purch_Org = "PS01";

poHeader.Pur_Group = "002";

//poHeader.Exch_Rate = 1;

poHeader.Incoterms1 = "FOB";

poHeader.Incoterms2 = "test po";

///////////////////////////////////

poHeaderX.Doc_Type = "X";

poHeaderX.Vendor = "X";

poHeaderX.Doc_Date = "X";

poHeaderX.Comp_Code = "X";

poHeaderX.Pmnttrms = "X";

//poHeaderX.Currency = "X";

poHeaderX.Purch_Org = "X";

poHeaderX.Pur_Group = "X";

//poHeaderX.Exch_Rate = "X";

poHeaderX.Incoterms1 = "X";

poHeaderX.Incoterms2 = "X";

poItem.Po_Item = "10";

//poItem.Item_Cat = "";

poItem.Material = "51014-0000J";

poItem.Short_Text = "ccpo";

poItem.Quantity = 1000;

poItem.Plant = "PS01";

poItem.Tax_Code = "11";

poItemTable.Add(poItem);

////////////////////////////////

poItemX.Po_Item = "10";

//poItemX.Item_Cat = "X";

poItemX.Material = "X";

poItemX.Short_Text = "X";

poItemX.Quantity = "X";

poItemX.Plant = "X";

poItemX.Tax_Code = "X";

poItemXTable.Add(poItemX);

poSch.Po_Item = "10";

poSch.Delivery_Date = "20050430";

poSch.Quantity = 1000;

poSchTable.Add(poSch);

poSchX.Po_Item = "10";

poSchX.Delivery_Date = "X";

poSchX.Quantity = "X";

poSchXTable.Add(poSchX);

bapi_PO1.Bapi_Po_Create1("","","","","","",addrv,eikp,eikpx,poHeader,poHeaderX,"",dcm,out expHeader,

out expeikp,out expPO,ref allversions,ref parexin,ref parexout,ref account,

ref accountp,ref accountx,ref addrd,ref cond,ref condheader,ref condheaderx,

ref condx,ref esucc,ref eipo,ref eipox,ref poItemTable,ref poItemXTable,

ref esuhc,ref ekkop,ref poSchTable,ref poSchXTable,ref esllc,ref eslltx,

ref esklc,ref texthead,ref text,ref ret2);

bapi_PO1.CommitWork();

string screenout = "";

foreach (DTP_PO.BAPIRET2 r in ret2)

{

screenout = screenout + r.Message + '\n';

}

MessageBox.Show(screenout,expPO);