简体   繁体   English

如何将数据从 SAP 表导入 Excel 表

[英]How can I import data from SAP Table to an Excel Sheet

I am new to Excel VBA.我是 Excel VBA 的新手。 I don't know how to get the data from SAP table to Excel sheet.我不知道如何将数据从 SAP 表获取到 Excel 表。

The query is.查询是。 I have one Excel sheet containing 10 fields.我有一张包含 10 个字段的 Excel 工作表。
Basing on pcode field (in Excel), PL will be imported from SAP table.基于pcode字段(在 Excel 中), PL将从 SAP 表中导入。

Example例子

ID | name  | pcode | PL (from SAP)
---+-------+-------+-----------------
1  | kiran | 1234  | 
2  | karan | 5001  | 

There's a lot of documentation online for writing into Excel sheets from VB, as there is a lot of documentation for reading SQL table data into VB, you can google these things and find what you need.网上有很多关于从 VB 写入 Excel 表格的文档,因为有很多用于将 SQL 表数据读入 VB 的文档,您可以在 google 上搜索这些内容并找到您需要的内容。 Something you might not find through Google is how to track down the tables you actually require.您可能无法通过 Google 找到的内容是如何追踪您实际需要的表格。 SAP data all comes from tables that I like to call "Background" tables. SAP 数据全部来自我喜欢称为“背景”表的表。 Although SAP presents all the data in a nice format which is easy on the eyes, it is all actually just a set of big ugly SQL tables.尽管 SAP 以一种很好看的格式呈现所有数据,但实际上它只是一组丑陋的大 SQL 表。 Lets say I want to extract all of the items that I have in stock (as far as SAP knows), then write this info into an excel sheet, here's where to begin:假设我想提取我库存中的所有项目(据 SAP 所知),然后将此信息写入 Excel 表,这里是开始的地方:

Firstly TURN ON SYSTEM INFORMATION.首先打开系统信息。 To do this, press Ctrl + Shift + I (or go to View -> system information), now when you hover over a field, the bar at the bottom of the SAP screen will tell you all of the background information that you'll need to find the location of the data in SQL.为此,请按 Ctrl + Shift + I(或转到“查看”->“系统信息”),现在当您将鼠标悬停在某个字段上时,SAP 屏幕底部的栏会告诉您所有的背景信息需要在SQL中找到数据的位置。

将鼠标悬停在某处,然后看这里!

When you hover your cursor over a field, the bar highlighted in this image should show something like this:当您将光标悬停在某个字段上时,此图像中突出显示的栏应显示如下内容:

Manual [Form = 142 Item = 38 Pane = 1 Column = 14700021 Row = 1 Variable = 11 POR1,UomCode]手册 [表单 = 142 项 = 38 窗格 = 1 列 = 14700021 行 = 1 变量 = 11 POR1,UomCode]

Here the parts we are interested are the "POR1, UomCode" Here, "POR1" will be the name of the SQL table which contains the data you're after, and "UomCode" is the column name.这里我们感兴趣的部分是“POR1,UomCode”。这里,“POR1”将是包含您要查找的数据的 SQL 表的名称,“UomCode”是列名称。

This example was for a purchase order, but for item master data this information will be different, the table name will be OITM, with item details being held in ITM1.此示例针对采购订单,但对于物料主数据,此信息将有所不同,表名称将为 OITM,物料详细信息保存在 ITM1 中。

And so you would contruct a SQL query which will bring through all the info you need from the tables, package it up into variables in whatever programming language you choose (I use VB.NET), then spit it out into Excel.因此,您将构建一个 SQL 查询,该查询将从表中获取您需要的所有信息,以您选择的任何编程语言(我使用 VB.NET)将其打包成变量,然后将其输出到 Excel 中。

Hope this helped!希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM