Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI for Goods Movement......

Former Member
0 Likes
624

I have posted this thread before too and I have got some replies and I have been told that I need to consult my functional guy but I just have one query, In my previous assignment I was provinding the GL account when the posting key was 40 and when the posting key was 50 I was providing the vendor number, but in this scenario I haven't provided the vendor number but provided the G/L account for both the possting keys, so was just wondering if I was doing it right or not

Code is below:

I am working on an interface where I am using BAPI_ACC_DOCUMENT_POST for posting an accounting document and I have not being provided with the vendor number but I have been provided with the G/L accounts for both the posting key 40 and 50 but when I am running this program, I am getting this error, <b>"Account 206221 in company code 1000 cannot be directly posted to</b>" and this G/L a/c is associated with posting key 50, can you please have a look at the following code and please let me know my mistake.

data: begin of it_input_file occurs 0,

pos_date(10),

bukrs(4),

pos_per(2),

currency(3),

h_text(25),

doc_type(2),

pos_key(2),

glaccount(10),

amount(16),

bus_area(4),

kostl(10),

item_text(50),

order(20),

allocation(10),

prctr(10),

doc_date(10),

end of it_input_file.

if it_input_file-pos_key eq 50.

move:

v_count to glaccount-ITEMNO_ACC,

it_input_file-glaccount to glaccount-gl_account,

it_input_file-kostl to glaccount-COSTCENTER,

it_input_file-prctr to glaccount-PROFIT_CTR,

it_input_file-bus_area to glaccount-bus_area,

it_input_file-item_text to glaccount-ITEM_TEXT.

append glaccount.

move:

v_count to currencyamount-ITEMNO_ACC,

it_input_file-currency to currencyamount-CURRENCY.

currencyamount-AMT_DOCCUR = it_input_file-amount * -1.

append currencyamount.

clear: glaccount, currencyamount.

else.

move:

v_count to glaccount-ITEMNO_ACC,

it_input_file-glaccount to glaccount-gl_account,

it_input_file-kostl to glaccount-COSTCENTER,

it_input_file-prctr to glaccount-PROFIT_CTR,

it_input_file-bus_area to glaccount-bus_area,

it_input_file-item_text to glaccount-ITEM_TEXT.

  • it_input_file-assignment to glaccount-ALLOC_NMBR.

append glaccount.

move:

v_count to currencyamount-ITEMNO_ACC,

it_input_file-currency to currencyamount-CURRENCY,

it_input_file-amount to currencyamount-AMT_DOCCUR .

append currencyamount.

clear: glaccount, currencyamount.

endif.

FORM call_bapi .

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

DOCUMENTHEADER = documentheader

IMPORTING

OBJ_TYPE = obj_type

OBJ_KEY = obj_key

OBJ_SYS = obj_sys

TABLES

ACCOUNTGL = glaccount

ACCOUNTPAYABLE = ap

CURRENCYAMOUNT = currencyamount

RETURN = return.

read table return with key type = 'S'.

if syst-subrc eq 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

IMPORTING

RETURN = return2.

perform create_success_log.

else.

perform create_failure_log.

endif.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
560

Hi Rajeev,

Here also your functional guy can help. You can check with him as do you need to pass vendor number or GL for posting key 50. If it is something with the coding then we can help.

Regards,

Atish

I have posted this thread before too and I have got some replies and I have been told that I need to consult my functional guy but I just have one query, In my previous assignment I was provinding the GL account when the posting key was 40 and when the posting key was 50 I was providing the vendor number, but in this scenario I haven't provided the vendor number but provided the G/L account for both the possting keys, so was just wondering if I was doing it right or not

Code is below:

I am working on an interface where I am using BAPI_ACC_DOCUMENT_POST for posting an accounting document and I have not being provided with the vendor number but I have been provided with the G/L accounts for both the posting key 40 and 50 but when I am running this program, I am getting this error, <b>"Account 206221 in company code 1000 cannot be directly posted to</b>" and this G/L a/c is associated with posting key 50, can you please have a look at the following code and please let me know my mistake.

data: begin of it_input_file occurs 0,

pos_date(10),

bukrs(4),

pos_per(2),

currency(3),

h_text(25),

doc_type(2),

pos_key(2),

glaccount(10),

amount(16),

bus_area(4),

kostl(10),

item_text(50),

order(20),

allocation(10),

prctr(10),

doc_date(10),

end of it_input_file.

if it_input_file-pos_key eq 50.

move:

v_count to glaccount-ITEMNO_ACC,

it_input_file-glaccount to glaccount-gl_account,

it_input_file-kostl to glaccount-COSTCENTER,

it_input_file-prctr to glaccount-PROFIT_CTR,

it_input_file-bus_area to glaccount-bus_area,

it_input_file-item_text to glaccount-ITEM_TEXT.

append glaccount.

move:

v_count to currencyamount-ITEMNO_ACC,

it_input_file-currency to currencyamount-CURRENCY.

currencyamount-AMT_DOCCUR = it_input_file-amount * -1.

append currencyamount.

clear: glaccount, currencyamount.

else.

move:

v_count to glaccount-ITEMNO_ACC,

it_input_file-glaccount to glaccount-gl_account,

it_input_file-kostl to glaccount-COSTCENTER,

it_input_file-prctr to glaccount-PROFIT_CTR,

it_input_file-bus_area to glaccount-bus_area,

it_input_file-item_text to glaccount-ITEM_TEXT.

  • it_input_file-assignment to glaccount-ALLOC_NMBR.

append glaccount.

move:

v_count to currencyamount-ITEMNO_ACC,

it_input_file-currency to currencyamount-CURRENCY,

it_input_file-amount to currencyamount-AMT_DOCCUR .

append currencyamount.

clear: glaccount, currencyamount.

endif.

FORM call_bapi .

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

DOCUMENTHEADER = documentheader

IMPORTING

OBJ_TYPE = obj_type

OBJ_KEY = obj_key

OBJ_SYS = obj_sys

TABLES

ACCOUNTGL = glaccount

ACCOUNTPAYABLE = ap

CURRENCYAMOUNT = currencyamount

RETURN = return.

read table return with key type = 'S'.

if syst-subrc eq 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

IMPORTING

RETURN = return2.

perform create_success_log.

else.

perform create_failure_log.

endif.

1 REPLY 1
Read only

Former Member
0 Likes
561

Hi Rajeev,

Here also your functional guy can help. You can check with him as do you need to pass vendor number or GL for posting key 50. If it is something with the coding then we can help.

Regards,

Atish