<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Header, Line Item and Cache Techniques Using Hashed Tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/header-line-item-and-cache-techniques-using-hashed-tables/m-p/3331082#M798098</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example to clarify the ideas: &lt;/P&gt;&lt;P&gt;In general, every time you have a header-&amp;gt; lines structure you have a unique key for the lines that has at least header key plus one or more fields. I'll make use of this fact. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll try to put an example of how to work with header -&amp;gt; line items and a cache technique using hashed tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just suppose that you need a list of all the material movements '101'-'901' for a certain range of dates in mkpf-budat. We'll extract these fields:&lt;/P&gt;&lt;P&gt;mkpf-budat&lt;/P&gt;&lt;P&gt;mkpf-mblnr,&lt;/P&gt;&lt;P&gt;mseg-lifnr,&lt;/P&gt;&lt;P&gt;lfa1-name1,&lt;/P&gt;&lt;P&gt;mkpf-xblnr,&lt;/P&gt;&lt;P&gt;mseg-zeile&lt;/P&gt;&lt;P&gt;mseg-charg,&lt;/P&gt;&lt;P&gt;mseg-matnr,&lt;/P&gt;&lt;P&gt;makt-maktx,&lt;/P&gt;&lt;P&gt;mseg-erfmg,&lt;/P&gt;&lt;P&gt;mseg-erfme.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll use two cache: one for maintaining lfa1 related data and the other to maintain makt related data. Also I'll only describe the data gathering part. The showing of the data is left to your own imagination.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The main ideas are: &lt;/P&gt;&lt;P&gt;1. As this is an example I won't use inner join. If properly desingned may be faster .&lt;/P&gt;&lt;P&gt;2. I'll use four hashed tables: ht_mkpf, ht_mseg, ht_lfa1 and ht_makt to get data into memory. Then I'll collect all the data I want to list into a fifth table ht_lst. &lt;/P&gt;&lt;P&gt;3. ht_mkpf should have (at least) mkpf's primary key fields : mjahr, mblnr. &lt;/P&gt;&lt;P&gt;4. ht_mseg should have (at least) mseg primary key fields: mjahr mblnr and zeile.&lt;/P&gt;&lt;P&gt;5. ht_lfa1 should have an unique key by lifnr.&lt;/P&gt;&lt;P&gt;6. ht_makt should have an unique key by matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;7. I prefer using with header line because makes the code easier to follow and understand. The waste of time isn't quite significant (in my experience at least). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: When I've needed to work from header to item lines then I added a counter in ht_header that maintains the count of item lines, and I added an id in the ht_lines so I can read straight by key a given item line. But this is very tricky to implement and to follow. (Nevertheless I've programmed it and it works well.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data will be read in this sequence:&lt;/P&gt;&lt;P&gt;select data from mkpf into table ht_mkpf&lt;/P&gt;&lt;P&gt;select data from mseg int table ht_mseg having in count all the data in ht_mkpf&lt;/P&gt;&lt;P&gt;loop at ht_mseg (lines) &lt;/P&gt;&lt;P&gt;filter unwanted records&lt;/P&gt;&lt;P&gt;read cache for lfa1 and makt&lt;/P&gt;&lt;P&gt;fill in ht_lst and collect data&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;tables&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;tables: mkpf, mseg, lfa1, makt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;internal tables:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of wa_mkpf, "header &lt;/P&gt;&lt;P&gt;mblnr like mkpf-mblnr,&lt;/P&gt;&lt;P&gt;mjahr like mkpf-mjahr,&lt;/P&gt;&lt;P&gt;budat like mkpf-budat,&lt;/P&gt;&lt;P&gt;xblnr like mkpf-xblnr,&lt;/P&gt;&lt;P&gt;end of wa_mkpf.&lt;/P&gt;&lt;P&gt;data ht_mkpf like hashed table of wa_mkpf&lt;/P&gt;&lt;P&gt;with unique key mblnr mjahr&lt;/P&gt;&lt;P&gt;with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of wa_mseg, " line items &lt;/P&gt;&lt;P&gt;mblnr like mseg-mblnr,&lt;/P&gt;&lt;P&gt;mjahr like mseg-mjahr,&lt;/P&gt;&lt;P&gt;zeile like mseg-zeile,&lt;/P&gt;&lt;P&gt;bwart like mseg-bwart,&lt;/P&gt;&lt;P&gt;charg like mseg-charg,&lt;/P&gt;&lt;P&gt;matnr like mseg-matnr,&lt;/P&gt;&lt;P&gt;lifnr like mseg-lifnr,&lt;/P&gt;&lt;P&gt;erfmg like mseg-erfmg,&lt;/P&gt;&lt;P&gt;erfme like mseg-erfme,&lt;/P&gt;&lt;P&gt;end of wa_mseg,&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;data ht_mseg like hashed table of wa_mseg&lt;/P&gt;&lt;P&gt;with unique key mblnr mjahr zeile&lt;/P&gt;&lt;P&gt;with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of wa_lfa1,&lt;/P&gt;&lt;P&gt;lifnr like lfa1-lifnr,&lt;/P&gt;&lt;P&gt;name1 like lfa1-name1,&lt;/P&gt;&lt;P&gt;end of wa_lfa1,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data ht_lfa1 like hashed table of wa_lfa1 &lt;/P&gt;&lt;P&gt;with unique key lifnr&lt;/P&gt;&lt;P&gt;with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of wa_makt,&lt;/P&gt;&lt;P&gt;matnr like makt-matnr,&lt;/P&gt;&lt;P&gt;maktx like makt-maktx,&lt;/P&gt;&lt;P&gt;end of wa_makt.&lt;/P&gt;&lt;P&gt;data: ht_makt like hashed table of wa_makt&lt;/P&gt;&lt;P&gt;with unique key matnr&lt;/P&gt;&lt;P&gt;with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;result table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;data: begin of wa_lst, " &lt;/P&gt;&lt;P&gt;budat like mkpf-budat,&lt;/P&gt;&lt;P&gt;mblnr like mseg-mblnr,&lt;/P&gt;&lt;P&gt;lifnr like mseg-lifnr,&lt;/P&gt;&lt;P&gt;name1 like lfa1-name1, &lt;/P&gt;&lt;P&gt;xblnr like mkpf-xblnr,&lt;/P&gt;&lt;P&gt;zeile like mseg-zeile,&lt;/P&gt;&lt;P&gt;charg like mseg-charg,&lt;/P&gt;&lt;P&gt;matnr like mseg-matnr,&lt;/P&gt;&lt;P&gt;maktx like makt-maktx,&lt;/P&gt;&lt;P&gt;erfmg like mseg-erfmg,&lt;/P&gt;&lt;P&gt;erfme like mseg-erfme,&lt;/P&gt;&lt;P&gt;mjahr like mseg-mjahr,&lt;/P&gt;&lt;P&gt;end of wa_mseg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: ht_lst like hashed table of wa_lst &lt;/P&gt;&lt;P&gt;with unique key mblnr mjahr zeile&lt;/P&gt;&lt;P&gt;with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: g_lines type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select-options: so_budat for mkpf-budat default sy-datum.&lt;/P&gt;&lt;P&gt;select-options: so_matnr for mseg-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form get_data.&lt;/P&gt;&lt;P&gt;select mblnr mjahr budat xblnr&lt;/P&gt;&lt;P&gt;into table ht_mkfp&lt;/P&gt;&lt;P&gt;from mkpf&lt;/P&gt;&lt;P&gt;where budat in so_budat.&lt;/P&gt;&lt;P&gt;describe table ht_mkpf lines g_lines. &lt;/P&gt;&lt;P&gt;if lines &amp;gt; 0.&lt;/P&gt;&lt;P&gt;select mblnr mjahr zeile bwart charg &lt;/P&gt;&lt;P&gt;matnr lifnr erfmg erfme&lt;/P&gt;&lt;P&gt;into table ht_mseg&lt;/P&gt;&lt;P&gt;from mseg &lt;/P&gt;&lt;P&gt;for all entries in ht_mkpf&lt;/P&gt;&lt;P&gt;where mblnr = ht_mkpf-mblnr &lt;/P&gt;&lt;P&gt;and mjahr = ht_mjahr.&lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;loop at ht_mseg.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;filter unwanted data &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.&lt;/P&gt;&lt;P&gt;check ht_mseg-matnr in so_matnr.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;read header line.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;read table ht_mkpf with table key mblnr = ht_mseg-mblnr &lt;/P&gt;&lt;P&gt;mjahr = ht_mseg-mjahr.&lt;/P&gt;&lt;P&gt;clear ht_lst.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;note : this may be faster if you specify field by field. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;move-corresponding ht_mkpf to ht_lst.&lt;/P&gt;&lt;P&gt;move-corresponding ht_mseg to ht_lst. &lt;/P&gt;&lt;P&gt;perform read_lfa1 using ht_mseg-lifnr changing ht_lst-name1. &lt;/P&gt;&lt;P&gt;perform read_makt using ht_mseg-matnr changing ht_lst-maktx.&lt;/P&gt;&lt;P&gt;insert table ht_lst.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;implementation of cache for lfa1.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;form read_lfa1 using p_lifnr changing p_name1.&lt;/P&gt;&lt;P&gt;read table ht_lfa1 with table key lifnr = p_lifnr&lt;/P&gt;&lt;P&gt;transporting name1.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;clear ht_lfa1.&lt;/P&gt;&lt;P&gt;ht_lfa1-lifnr = p_lifnr.&lt;/P&gt;&lt;P&gt;select single name1 &lt;/P&gt;&lt;P&gt;into ht_lfa1-name1 &lt;/P&gt;&lt;P&gt;from lfa1 &lt;/P&gt;&lt;P&gt;where lifnr = p_lifnr.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0. ht_lfa1-name1 = 'n/a in lfa1'. endif.&lt;/P&gt;&lt;P&gt;insert table ht_lfa1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;p_name1 = ht_lfa1-name1.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;implementation of cache for makt&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;form read_makt using p_matnr changing p_maktx.&lt;/P&gt;&lt;P&gt;read table ht_makt with table key matnr = p_matnr&lt;/P&gt;&lt;P&gt;transporting maktx.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0. &lt;/P&gt;&lt;P&gt;ht_makt-matnr = p_matnr.&lt;/P&gt;&lt;P&gt;select single maktx into ht_matk-maktx &lt;/P&gt;&lt;P&gt;from makt&lt;/P&gt;&lt;P&gt;where spras = sy-langu&lt;/P&gt;&lt;P&gt;and matnr = p_matnr.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0. ht_makt-maktx = 'n/a in makt'. endif.&lt;/P&gt;&lt;P&gt;insert table ht_makt. &lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;p_maktx = ht_makt-maktx.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reward points if found helpfull...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Cheers,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Siva.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 27 Jan 2008 10:24:22 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-01-27T10:24:22Z</dc:date>
    <item>
      <title>Header, Line Item and Cache Techniques Using Hashed Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/header-line-item-and-cache-techniques-using-hashed-tables/m-p/3331081#M798097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I work with header, line item, and a cache techniques using hashed tables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shah.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2008 13:33:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/header-line-item-and-cache-techniques-using-hashed-tables/m-p/3331081#M798097</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-26T13:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Header, Line Item and Cache Techniques Using Hashed Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/header-line-item-and-cache-techniques-using-hashed-tables/m-p/3331082#M798098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example to clarify the ideas: &lt;/P&gt;&lt;P&gt;In general, every time you have a header-&amp;gt; lines structure you have a unique key for the lines that has at least header key plus one or more fields. I'll make use of this fact. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll try to put an example of how to work with header -&amp;gt; line items and a cache technique using hashed tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just suppose that you need a list of all the material movements '101'-'901' for a certain range of dates in mkpf-budat. We'll extract these fields:&lt;/P&gt;&lt;P&gt;mkpf-budat&lt;/P&gt;&lt;P&gt;mkpf-mblnr,&lt;/P&gt;&lt;P&gt;mseg-lifnr,&lt;/P&gt;&lt;P&gt;lfa1-name1,&lt;/P&gt;&lt;P&gt;mkpf-xblnr,&lt;/P&gt;&lt;P&gt;mseg-zeile&lt;/P&gt;&lt;P&gt;mseg-charg,&lt;/P&gt;&lt;P&gt;mseg-matnr,&lt;/P&gt;&lt;P&gt;makt-maktx,&lt;/P&gt;&lt;P&gt;mseg-erfmg,&lt;/P&gt;&lt;P&gt;mseg-erfme.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll use two cache: one for maintaining lfa1 related data and the other to maintain makt related data. Also I'll only describe the data gathering part. The showing of the data is left to your own imagination.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The main ideas are: &lt;/P&gt;&lt;P&gt;1. As this is an example I won't use inner join. If properly desingned may be faster .&lt;/P&gt;&lt;P&gt;2. I'll use four hashed tables: ht_mkpf, ht_mseg, ht_lfa1 and ht_makt to get data into memory. Then I'll collect all the data I want to list into a fifth table ht_lst. &lt;/P&gt;&lt;P&gt;3. ht_mkpf should have (at least) mkpf's primary key fields : mjahr, mblnr. &lt;/P&gt;&lt;P&gt;4. ht_mseg should have (at least) mseg primary key fields: mjahr mblnr and zeile.&lt;/P&gt;&lt;P&gt;5. ht_lfa1 should have an unique key by lifnr.&lt;/P&gt;&lt;P&gt;6. ht_makt should have an unique key by matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;7. I prefer using with header line because makes the code easier to follow and understand. The waste of time isn't quite significant (in my experience at least). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: When I've needed to work from header to item lines then I added a counter in ht_header that maintains the count of item lines, and I added an id in the ht_lines so I can read straight by key a given item line. But this is very tricky to implement and to follow. (Nevertheless I've programmed it and it works well.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data will be read in this sequence:&lt;/P&gt;&lt;P&gt;select data from mkpf into table ht_mkpf&lt;/P&gt;&lt;P&gt;select data from mseg int table ht_mseg having in count all the data in ht_mkpf&lt;/P&gt;&lt;P&gt;loop at ht_mseg (lines) &lt;/P&gt;&lt;P&gt;filter unwanted records&lt;/P&gt;&lt;P&gt;read cache for lfa1 and makt&lt;/P&gt;&lt;P&gt;fill in ht_lst and collect data&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;tables&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;tables: mkpf, mseg, lfa1, makt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;internal tables:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of wa_mkpf, "header &lt;/P&gt;&lt;P&gt;mblnr like mkpf-mblnr,&lt;/P&gt;&lt;P&gt;mjahr like mkpf-mjahr,&lt;/P&gt;&lt;P&gt;budat like mkpf-budat,&lt;/P&gt;&lt;P&gt;xblnr like mkpf-xblnr,&lt;/P&gt;&lt;P&gt;end of wa_mkpf.&lt;/P&gt;&lt;P&gt;data ht_mkpf like hashed table of wa_mkpf&lt;/P&gt;&lt;P&gt;with unique key mblnr mjahr&lt;/P&gt;&lt;P&gt;with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of wa_mseg, " line items &lt;/P&gt;&lt;P&gt;mblnr like mseg-mblnr,&lt;/P&gt;&lt;P&gt;mjahr like mseg-mjahr,&lt;/P&gt;&lt;P&gt;zeile like mseg-zeile,&lt;/P&gt;&lt;P&gt;bwart like mseg-bwart,&lt;/P&gt;&lt;P&gt;charg like mseg-charg,&lt;/P&gt;&lt;P&gt;matnr like mseg-matnr,&lt;/P&gt;&lt;P&gt;lifnr like mseg-lifnr,&lt;/P&gt;&lt;P&gt;erfmg like mseg-erfmg,&lt;/P&gt;&lt;P&gt;erfme like mseg-erfme,&lt;/P&gt;&lt;P&gt;end of wa_mseg,&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;data ht_mseg like hashed table of wa_mseg&lt;/P&gt;&lt;P&gt;with unique key mblnr mjahr zeile&lt;/P&gt;&lt;P&gt;with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of wa_lfa1,&lt;/P&gt;&lt;P&gt;lifnr like lfa1-lifnr,&lt;/P&gt;&lt;P&gt;name1 like lfa1-name1,&lt;/P&gt;&lt;P&gt;end of wa_lfa1,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data ht_lfa1 like hashed table of wa_lfa1 &lt;/P&gt;&lt;P&gt;with unique key lifnr&lt;/P&gt;&lt;P&gt;with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of wa_makt,&lt;/P&gt;&lt;P&gt;matnr like makt-matnr,&lt;/P&gt;&lt;P&gt;maktx like makt-maktx,&lt;/P&gt;&lt;P&gt;end of wa_makt.&lt;/P&gt;&lt;P&gt;data: ht_makt like hashed table of wa_makt&lt;/P&gt;&lt;P&gt;with unique key matnr&lt;/P&gt;&lt;P&gt;with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;result table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;data: begin of wa_lst, " &lt;/P&gt;&lt;P&gt;budat like mkpf-budat,&lt;/P&gt;&lt;P&gt;mblnr like mseg-mblnr,&lt;/P&gt;&lt;P&gt;lifnr like mseg-lifnr,&lt;/P&gt;&lt;P&gt;name1 like lfa1-name1, &lt;/P&gt;&lt;P&gt;xblnr like mkpf-xblnr,&lt;/P&gt;&lt;P&gt;zeile like mseg-zeile,&lt;/P&gt;&lt;P&gt;charg like mseg-charg,&lt;/P&gt;&lt;P&gt;matnr like mseg-matnr,&lt;/P&gt;&lt;P&gt;maktx like makt-maktx,&lt;/P&gt;&lt;P&gt;erfmg like mseg-erfmg,&lt;/P&gt;&lt;P&gt;erfme like mseg-erfme,&lt;/P&gt;&lt;P&gt;mjahr like mseg-mjahr,&lt;/P&gt;&lt;P&gt;end of wa_mseg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: ht_lst like hashed table of wa_lst &lt;/P&gt;&lt;P&gt;with unique key mblnr mjahr zeile&lt;/P&gt;&lt;P&gt;with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: g_lines type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select-options: so_budat for mkpf-budat default sy-datum.&lt;/P&gt;&lt;P&gt;select-options: so_matnr for mseg-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form get_data.&lt;/P&gt;&lt;P&gt;select mblnr mjahr budat xblnr&lt;/P&gt;&lt;P&gt;into table ht_mkfp&lt;/P&gt;&lt;P&gt;from mkpf&lt;/P&gt;&lt;P&gt;where budat in so_budat.&lt;/P&gt;&lt;P&gt;describe table ht_mkpf lines g_lines. &lt;/P&gt;&lt;P&gt;if lines &amp;gt; 0.&lt;/P&gt;&lt;P&gt;select mblnr mjahr zeile bwart charg &lt;/P&gt;&lt;P&gt;matnr lifnr erfmg erfme&lt;/P&gt;&lt;P&gt;into table ht_mseg&lt;/P&gt;&lt;P&gt;from mseg &lt;/P&gt;&lt;P&gt;for all entries in ht_mkpf&lt;/P&gt;&lt;P&gt;where mblnr = ht_mkpf-mblnr &lt;/P&gt;&lt;P&gt;and mjahr = ht_mjahr.&lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;loop at ht_mseg.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;filter unwanted data &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.&lt;/P&gt;&lt;P&gt;check ht_mseg-matnr in so_matnr.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;read header line.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;read table ht_mkpf with table key mblnr = ht_mseg-mblnr &lt;/P&gt;&lt;P&gt;mjahr = ht_mseg-mjahr.&lt;/P&gt;&lt;P&gt;clear ht_lst.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;note : this may be faster if you specify field by field. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;move-corresponding ht_mkpf to ht_lst.&lt;/P&gt;&lt;P&gt;move-corresponding ht_mseg to ht_lst. &lt;/P&gt;&lt;P&gt;perform read_lfa1 using ht_mseg-lifnr changing ht_lst-name1. &lt;/P&gt;&lt;P&gt;perform read_makt using ht_mseg-matnr changing ht_lst-maktx.&lt;/P&gt;&lt;P&gt;insert table ht_lst.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;implementation of cache for lfa1.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;form read_lfa1 using p_lifnr changing p_name1.&lt;/P&gt;&lt;P&gt;read table ht_lfa1 with table key lifnr = p_lifnr&lt;/P&gt;&lt;P&gt;transporting name1.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;clear ht_lfa1.&lt;/P&gt;&lt;P&gt;ht_lfa1-lifnr = p_lifnr.&lt;/P&gt;&lt;P&gt;select single name1 &lt;/P&gt;&lt;P&gt;into ht_lfa1-name1 &lt;/P&gt;&lt;P&gt;from lfa1 &lt;/P&gt;&lt;P&gt;where lifnr = p_lifnr.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0. ht_lfa1-name1 = 'n/a in lfa1'. endif.&lt;/P&gt;&lt;P&gt;insert table ht_lfa1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;p_name1 = ht_lfa1-name1.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;implementation of cache for makt&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;form read_makt using p_matnr changing p_maktx.&lt;/P&gt;&lt;P&gt;read table ht_makt with table key matnr = p_matnr&lt;/P&gt;&lt;P&gt;transporting maktx.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0. &lt;/P&gt;&lt;P&gt;ht_makt-matnr = p_matnr.&lt;/P&gt;&lt;P&gt;select single maktx into ht_matk-maktx &lt;/P&gt;&lt;P&gt;from makt&lt;/P&gt;&lt;P&gt;where spras = sy-langu&lt;/P&gt;&lt;P&gt;and matnr = p_matnr.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0. ht_makt-maktx = 'n/a in makt'. endif.&lt;/P&gt;&lt;P&gt;insert table ht_makt. &lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;p_maktx = ht_makt-maktx.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reward points if found helpfull...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Cheers,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Siva.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Jan 2008 10:24:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/header-line-item-and-cache-techniques-using-hashed-tables/m-p/3331082#M798098</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-27T10:24:22Z</dc:date>
    </item>
  </channel>
</rss>

