cancel
Showing results for 
Search instead for 
Did you mean: 

Customization to Upload bills in PR05

yogesh_galphade
Contributor
0 Kudos

Dear Experts

I want to develop a webdynpro java application which will upload the bills in PR05.

Please give your inputs if you have gone through scenario.

-Yogesh

Edited by: Yogesh Galphade on Jun 26, 2009 5:59 PM

Accepted Solutions (1)

Accepted Solutions (1)

shreyas_pandya
Contributor
0 Kudos

Dear Yogesh,

There's one standard BAPI available named "Archiv_Create_Table".

you can import this BAPI into your custom web dynpro java application as a model.

It contains 5 import parameters...

1> Ar_Object

2> Object_Id

3> Sap_Object

4> Doc_Type

5> Document

The 5th parameter "Document", is where we need to pass the file that will be uploaded from the web dynpro application.

in ABAP this import parameter is of type called "XSTRING", so it's counterpart type in Java is Byte Array (byte[])

Create a below mentioned method in the //@@begin others...... //@@end section.

This method takes an Input Stream as a parameter & returns a Byte Array (byte[]).

//@@begin others


Archiv_Create_Table_Input input =null; // Bapi object declaration.
public byte[] getByteArray(InputStream ipStr) 
  {
  	byte[] bytArr = null;
	try
	{
		bytArr = new byte[ipStr.available()];
	} 
	catch (IOException e) 
	{
		e.printStackTrace();
  	}
  	try 
  	{
  		ipStr.read(bytArr);
	} 
	catch (IOException e1) 
	{
		e1.printStackTrace();
	}
	return bytArr;
  }

//@@end

Now, set all the import parameters of the BAPI according to your business criteria...


input = new Archiv_Create_Table_Input(); // bapi object instantiation.
input.setAr_Object("HRITRVEDOC");
input.setObject_Id("pernr"+"reinr"); // here "pernr" is Employee ID & "reinr" is Trip ID, both concatenated in string format.
input.setSap_Object("TRAVEL");
input.setDoc_Type("PDF");
InputStream ist=res.read(true);
input.setDocument(getByteArray(ist)); // method to return attached file in Byte Array format.
wdContext.nodeArchiv_Create_Table_Input().bind(input);
input.execute();

Please try this out and revert.

Regards,

Shreyas Pandya

Answers (0)