Using RunBaseBatch Class for Posting Invoice Of PurchaseOrder


Hello Friends,

Today i have created a Runbase batch class for Posting the Invoice of purchorder from the customized form.Which will post the invoice of selected records(purchase orders) from the Customized Form...

Let me explain you clearly...

Below you can see the screen shot of a customized Form

untitled

In the above form the records are inserting from Purchtable to customized form...

In that Form if i check the Ok Field for 1 or many records and click OK button.

All the records which are checked OK sholud be Posted Invoiced automatically here itself  no need of going again PurchOrder details form and the logic should run On SERVER...  

So I created a class of Invoice_PickUpPO

class declaration:

class Invoice_PickUpPO extends RunBaseBatch

{

//packed variables

#define.CurrentVersion(1)

PickUpReconcil pickUpReconcil;

}

CanGoBatchJournal Method:

public boolean canGoBatchJournal()

{

return true;

}

Pack Method:

public container pack()

{

return [#CurrentVersion];

}

Run Method:

public void run()

{

#OCCRetryCount

try

{

this.postPurchInvoice();

}

catch (Exception::Deadlock)

{

retry;

}

catch (Exception::UpdateConflict)

{

if (appl.ttsLevel() == 0)

{

if (xSession::currentRetryCount() >= #RetryNum)

{

throw Exception::UpdateConflictNotRecovered;

}

else

{

retry;

}

}

else

{

throw Exception::UpdateConflict;

}

}

catch (Exception::Error)

{

info('An error occurred while inserting the Data');

}}

RunImpersonated Method:

public boolean runsImpersonated()

{

return true;

}

UnPack Method:

public boolean unpack(container packedClass)

{

Version version = RunBase::getVersion(packedClass);

;

switch (version)

{

case #CurrentVersion:

[version] = packedClass;

break;

default:

return false;

}

return true;

}

Construct Method:

server static Invoice_PickUpPO construct()

{

return new Invoice_PickUpPO();

}

Description Method:

// Here goes a description of the class

static ClassDescription description()

{

return "Posting PurchOrder Invoice ";

}

Main Method

static void main(Args args)

{

Invoice_PickUpPO    Invoice_PickUpPO;

;

Invoice_PickUpPO = Invoice_PickUpPO::construct();

Invoice_PickUpPO.showBatchTab(false);

Invoice_PickUpPO.run();

}

PostPurchInvoice Mehtod:

void postPurchInvoice()

{

PurchFormLetter_Invoice     invoice;

Purchid                     purchid;

Purchtable                  purchtable;

;

while select pickUpReconcil where PickUpReconcil.OK == NoYes::Yes

{

Purchtable = Purchtable::find(PickUpReconcil.PONumber);

invoice = PurchFormletter::construct(DocumentStatus::Invoice);

invoice.update(purchtable,purchid,

SystemDateGet(),

PurchUpdate::All,

AccountOrder::None,

NoYes::No,

NoYes::No,

false,

true);

}

}

You can see in Main Method i have given  showBatchTab(false) where the logic run directly without prompting the dialog and batch...

In PostPurchInvoice Method i have written the code for Posting the PurchOrder for Invoice

Happy Da6ng...

No comments:

Post a Comment