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

Function module that returns material GL account number

Former Member
0 Likes
2,249

Hi All,

As a valuation class is assign to a material, I want a function module that allows me through material number, plant and a transaction from t_code OBYC (e.g. GBB u201COffsetting entry for inventory postingu201D), returns me GL account number of that material.

Can anyone help me?

Best regards,

LF

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
911

Hello

Try this snippet:


SELECT SINGLE * FROM MBEW WHERE MATNR EQ P_MATNR. " <= material
SELECT SINGLE * FROM T001K WHERE BWKEY EQ BWKEY.  " <= plant
IF SY-SUBRC = 0.
  SELECT SINGLE * FROM T001 WHERE BUKRS EQ T001K-BUKRS.
  IF SY-SUBRC = 0.
    SELECT SINGLE * FROM T030 WHERE KTOPL EQ T001-KTOPL
                                AND KTOSL EQ 'GBB'  " <= transaction
                                AND BWMOD EQ T001K-BWMOD
                                AND BKLAS EQ MBEW-BKLAS.
    IF SY-SUBRC = 0.
      WRITE: 'DEBIT ACCOUNT', T030-KONTS,
             'CREDIT ACCOUNT', T030-KONTH.
    ENDIF.
  ENDIF.  
ENDIF.

2 REPLIES 2
Read only

Former Member
0 Likes
912

Hello

Try this snippet:


SELECT SINGLE * FROM MBEW WHERE MATNR EQ P_MATNR. " <= material
SELECT SINGLE * FROM T001K WHERE BWKEY EQ BWKEY.  " <= plant
IF SY-SUBRC = 0.
  SELECT SINGLE * FROM T001 WHERE BUKRS EQ T001K-BUKRS.
  IF SY-SUBRC = 0.
    SELECT SINGLE * FROM T030 WHERE KTOPL EQ T001-KTOPL
                                AND KTOSL EQ 'GBB'  " <= transaction
                                AND BWMOD EQ T001K-BWMOD
                                AND BKLAS EQ MBEW-BKLAS.
    IF SY-SUBRC = 0.
      WRITE: 'DEBIT ACCOUNT', T030-KONTS,
             'CREDIT ACCOUNT', T030-KONTH.
    ENDIF.
  ENDIF.  
ENDIF.

Read only

Former Member
0 Likes
911

FM KPPB_MAT_ACCOUNT_ASSIGNMENT

Not exactly what you need. Just for information.