Skip to Content
author's profile photo Former Member
Former Member

Why "You do not have authorization to display company codes" ? Thanks

Hello,

Using the Tutorial BAPI which comes with the JCO Tutorial,I just wanna call the first function.

When I run the code, it display "You do not have authorization to display company codes".

Could any body please help me to explain why?

Thanks a lot

BELOW IS THE CODE:

package com.sap.slc.teamweb.test;

import com.sap.mw.jco.*;

public class TestBapi1 extends Object {

JCO.Client mConnection;

JCO.Repository mRepository;

public TestBapi1() {

try {

// Change the logon information to your own system/user

JCO.createClient("001", // SAP client

"<userid>", // userid

"****", // password

null, // language

"<hostname>", // application server host name

"00"); // system number

mConnection.connect();

mRepository = new JCO.Repository("SAPJCO", mConnection);

} catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

JCO.Function function = null;

JCO.Table codes = null;

try {

function = this.createFunction("BAPI_COMPANYCODE_GETLIST");

if (function == null) {

System.out.println("BAPI_COMPANYCODE_GETLIST" + " not found in SAP.");

System.exit(1);

}

mConnection.execute(function);

JCO.Structure returnStructure = function.getExportParameterList().getStructure("RETURN");

if (!(returnStructure.getString("TYPE").equals("") || returnStructure.getString("TYPE").equals("S"))) {

System.out.println(returnStructure.getString("MESSAGE"));

System.exit(1);

}

codes = function.getTableParameterList().getTable("COMPANYCODE_LIST");

for (int i = 0; i < codes.getNumRows(); i++) {

codes.setRow(i);

System.out.println(codes.getString("COMP_CODE") + '\t' + codes.getString("COMP_NAME"));

}

}

catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

try {

codes.firstRow();

for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow()) {

function = this.createFunction("BAPI_COMPANYCODE_GETDETAIL");

if (function == null) {

System.out.println("BAPI_COMPANYCODE_GETDETAIL" + " not found in SAP.");

System.exit(1);

}

function.getImportParameterList().

setValue(codes.getString("COMP_CODE"), "COMPANYCODEID");

function.getExportParameterList().

setActive(false, "COMPANYCODE_ADDRESS");

mConnection.execute(function);

JCO.Structure returnStructure = function.getExportParameterList().getStructure("RETURN");

if (!(returnStructure.getString("TYPE").equals("") ||

returnStructure.getString("TYPE").equals("S") ||

returnStructure.getString("TYPE").equals("W"))) {

System.out.println(returnStructure.getString("MESSAGE"));

}

JCO.Structure detail =

function.getExportParameterList().

getStructure("COMPANYCODE_DETAIL");

System.out.println(detail.getString("COMP_CODE") + '\t' +

detail.getString("COUNTRY") + '\t' +

detail.getString("CITY"));

}

}

catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

mConnection.disconnect();

}

public JCO.Function createFunction(String name) throws Exception {

try {

IFunctionTemplate ft = mRepository.getFunctionTemplate(name.toUpperCase());

if (ft == null)

return null;

return ft.getFunction();

}

catch (Exception ex) {

throw new Exception("Problem retrieving JCO.Function object.");

}

}

public static void main(String args[]) {

TestBapi1 app = new TestBapi1();

}

}

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 30, 2005 at 04:34 AM

    Hi Mao,

    The UserId ur paasing to JCo.createClient do not have authorization to display Company Codes. This is a Basis problem, ask ur Basis administrator to give required authorization to that UserId.

    Hope it helps you.

    Regards,

    Narinder Hartala

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2005 at 05:43 AM

    Hi Mao,

    R/3 comes with some predefined Company Codes and we also

    can define our own Company Codes.

    visit this link this may help you.

    http://help.sap.com/saphelp_erp2004/helpdata/en/8e/1a5217171311d28e1d080009b6ab29/frameset.htm

    Regards,

    Narinder Hartala

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.