用ABAP写一个创建会计科目的代码
时间: 2023-05-31 22:04:21 浏览: 180
以下是一个简单的ABAP代码,用于创建会计科目:
REPORT z_create_account.
DATA: lv_gl_account TYPE skat-kschl,
lv_account_name TYPE skat-ktext,
lv_account_type TYPE skat-ktopl,
lv_account_currency TYPE skat-waers.
PARAMETERS: p_gl_account TYPE skat-kschl,
p_account_name TYPE skat-ktext,
p_account_type TYPE skat-ktopl,
p_account_currency TYPE skat-waers.
* 检查输入参数是否有效
IF p_gl_account IS INITIAL OR p_account_name IS INITIAL OR
p_account_type IS INITIAL OR p_account_currency IS INITIAL.
MESSAGE 'Please enter all required fields' TYPE 'E'.
ENDIF.
* 设置创建会计科目的数据
lv_gl_account = p_gl_account.
lv_account_name = p_account_name.
lv_account_type = p_account_type.
lv_account_currency = p_account_currency.
* 创建会计科目
TRY.
INSERT INTO skat (kschl, ktext, ktopl, waers)
VALUES (lv_gl_account, lv_account_name, lv_account_type, lv_account_currency).
COMMIT WORK.
MESSAGE 'Account created successfully' TYPE 'S'.
CATCH cx_sy_sql_error INTO DATA(lx_sql_error).
MESSAGE lx_sql_error->get_text( ) TYPE 'E'.
ENDTRY.
阅读全文