for index, (invoice_info, details_infos) in enumerate(zip(details, invoice_details)): for line_detail in details_infos: line_item_name = ignore_special_symbols(try2get(line_detail, item_name_keys)) line_item_price = line_detail['单价'] if line_item_name in item_name_map.keys(): item_name_map[line_item_name][0].append(xor_float_r2(line_item_price)) item_name_map[line_item_name][1].append(index) else: if not line_item_name: continue item_name_map.update({line_item_name: ([xor_float_r2(line_item_price)], [index])})将这段代码简化
时间: 2024-02-05 16:03:12 浏览: 150
这段代码的作用是将发票信息中的每个条目的名称和价格存储到一个字典中,字典的键是名称,值是一个元组列表,元组中包含价格和该条目在发票信息中的索引。
代码简化后如下:
```
for invoice_info, details_infos in zip(details, invoice_details):
for line_detail in details_infos:
line_item_name = ignore_special_symbols(try2get(line_detail, item_name_keys))
line_item_price = line_detail['单价']
if not line_item_name:
continue
if line_item_name in item_name_map:
item_name_map[line_item_name][0].append(xor_float_r2(line_item_price))
item_name_map[line_item_name][1].append(index)
else:
item_name_map[line_item_name] = ([xor_float_r2(line_item_price)], [index])
```
相关问题
rv_invoice_document_read demo
rv_invoice_document_read is a function module used in SAP to read invoice documents. It takes input parameters such as invoice document number and company code and returns a set of output parameters such as invoice header data, item data, tax data, and payment data.
Here is a sample code demonstrating the use of rv_invoice_document_read function module:
```
DATA: ls_invoice_header TYPE bapi_incinv_create_header,
lt_invoice_items TYPE TABLE OF bapi_incinv_create_item,
lt_invoice_taxes TYPE TABLE OF bapi_incinv_create_tax,
lt_invoice_payments TYPE TABLE OF bapi_incinv_create_payment.
CALL FUNCTION 'RV_INVOICE_DOCUMENT_READ'
EXPORTING
companycode = '1000'
invoiceno = '123456'
IMPORTING
invoiceheader = ls_invoice_header
TABLES
invoiceitem = lt_invoice_items
invoicetax = lt_invoice_taxes
invoicepayment = lt_invoice_payments.
```
In this example, we are reading the invoice document with number '123456' and company code '1000'. The function module retrieves the invoice header data into the structure ls_invoice_header, the item data into the table lt_invoice_items, the tax data into the table lt_invoice_taxes and the payment data into the table lt_invoice_payments. This data can then be further processed as per the requirements of the business scenario.
RV_INVOICE_DOCUMENT_READ 写一个DEMO
RV_INVOICE_DOCUMENT_READ是一个SAP函数模块,用于读取SAP FI发票(Invoice)的相关信息。以下是一个简单的DEMO:
```
REPORT demo_rv_invoice_document_read.
DATA: lv_invoice_doc_num TYPE rbkp-belnr, " 发票号码
lt_invoice_items TYPE TABLE OF rseg, " 发票行项目
lt_invoice_tax TYPE TABLE OF bset. " 发票税额
* 设置发票号码
lv_invoice_doc_num = '10000001'.
* 调用函数模块 RV_INVOICE_DOCUMENT_READ
CALL FUNCTION 'RV_INVOICE_DOCUMENT_READ'
EXPORTING
belnr = lv_invoice_doc_num " 发票号码
TABLES
rseg_tab = lt_invoice_items " 发票行项目
bset_tab = lt_invoice_tax. " 发票税额
* 输出发票行项目信息
IF lt_invoice_items IS NOT INITIAL.
WRITE: / 'Invoice Items:'.
LOOP AT lt_invoice_items INTO DATA(ls_item).
WRITE: / ls_item-buzei, ls_item-hkont, ls_item-dmbtr.
ENDLOOP.
ENDIF.
* 输出发票税额信息
IF lt_invoice_tax IS NOT INITIAL.
WRITE: / 'Invoice Tax:'.
LOOP AT lt_invoice_tax INTO DATA(ls_tax).
WRITE: / ls_tax-shkzg, ls_tax-saknr, ls_tax-betrg.
ENDLOOP.
ENDIF.
```
注意:在实际使用中,需要根据具体的业务场景和需求,进行相应的参数设置和数据处理。
阅读全文
相关推荐















