如何更新ABAP哈希表

时间:2015-08-28 12:18:02

标签: hashtable updates abap

如何更新ABAP Hased表?

Java语句的等价物是什么:

$(document).ready(function() {

    //current time at document ready
    var past = new Date().getTime();

    $('#button').on('click', function() {

        //how much minutes passed when button clicked 
       timeElapsedInMin = Math.floor((new Date().getTime() - past) / 60000);
        ga('send', 'event', 'button', 'click', 'nav-buttons', timeElapsedInMin);
    });

});

在ABAP?

2 个答案:

答案 0 :(得分:7)

Assuming that you are only interested in the effect put() has on the content of hashMap and don't care about the value it returns, the equivalent would be:

INSERT VALUE #( KEY = 'myKey' VALUE = 'myValue' ) INTO TABLE hashMap.

With the difference that for an existing key the entry will not be updated but SY-SUBRC will be set to 4, so you'd have to do some extra work. Internal table hashMap needs to be defined as a HASHED TABLE WITH UNIQUE KEY KEY and a type that has at least the fields KEY and VALUE.

Also see: SAP Help

答案 1 :(得分:6)

工作示例:

TYPES: BEGIN OF LINE,
    COL1,
    COL2,
  END OF LINE.

DATA:   WA TYPE LINE,
      ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1.

WA-COL1 = 'X'. INSERT WA INTO TABLE ITAB.
WA-COL1 = 'Y'. INSERT WA INTO TABLE ITAB.
WA-COL1 = 'Y'. INSERT WA INTO TABLE ITAB. "Not added