{"id":1554,"date":"2016-08-26T11:04:10","date_gmt":"2016-08-26T10:04:10","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=1554"},"modified":"2016-08-26T11:11:37","modified_gmt":"2016-08-26T10:11:37","slug":"abap-get-handling-units-in-a-shipment","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=1554","title":{"rendered":"ABAP &#8211; Get handling units in a Shipment"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"358\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=358\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" data-orig-size=\"44,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Picasa&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1365690880&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"SAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" class=\"size-full wp-image-358 alignleft\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" alt=\"SAP\" width=\"44\" height=\"50\" \/>In this code snippet I&#8217;ll show how you can get info about all the handling units in a shipment delivery.<!--more-->A shipment can contain 1..* deliveries. S first of all you need to get all deliveries in the shipment:<\/p>\n<pre lang=\"abap\">DATA:\r\n  lt_vbeln    TYPE TABLE OF vbeln,\r\n  iv_shipment TYPE vttp-tknum VALUE '1234567'.  \"Your shipment number\r\n\r\nSELECT vbeln \r\n  INTO TABLE lt_vbeln\r\n  FROM vttp \r\n  WHERE tknum = iv_shipment.<\/pre>\n<p>To view a shipment, go to TCode VT03N and use your shipment number.<\/p>\n<p>To view deliveries contained in the shipment, go to Top Menu -&gt; GoTo -&gt; Shipments and Deliveries and double click on a delivery you want to see (or use directly Tcode VL03N and enter the delivery number).<\/p>\n<p>To view handling units in the delivery, press Ctrl+F6 (or the &#8220;box&#8221; icon in the top toolbar).<\/p>\n<p>&#8230;this was the SAPGUI approach to inspect the HU&#8217;s in a delivery&#8230;now comes the coding part<\/p>\n<p>At first I&#8217;ll show the approach using the standard function module to get all the necessary information about HU&#8217;s in a delivery:<\/p>\n<pre lang=\"abap\">DATA: \r\n  iv_delivery TYPE vbeln VALUE '2016280854' \"Your delivery number from shipment.\r\n  ls_object   TYPE hum_object.\r\n\r\n  lt_hus      TYPE hum_hu_header_t,\r\n  lt_hupos    TYPE hum_hu_item_t,\r\n  lt_serialno TYPE vsep_t_rserob.\r\n\r\nls_object-object = '01'. \"Delivery\r\nls_object-objkey = lv_delivery.\r\n\r\nCALL FUNCTION 'HU_GET_HUS'\r\n  EXPORTING\r\n    if_lock_hus      = 'X'\r\n    if_with_text     = ' '\r\n    is_objects       = ls_object\r\n  IMPORTING\r\n    et_header        = lt_hus\r\n    et_items         = lt_hupos\r\n    et_item_serialno = lt_serialno\r\n  EXCEPTIONS\r\n    hus_locked       = 1\r\n    no_hu_found      = 2\r\n    fatal_error      = 3\r\n    OTHERS           = 4.<\/pre>\n<p>The above code is great if you need information about one delivery.<\/p>\n<p>Maybe you ask why I used the &#8220;magic constant&#8221; <em>01\u00a0<\/em>for the <em>ls_object-object.<\/em> This field is connected to the VEKP-VPOBJ field which can contain the following values<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/VEKP_VPOBJ.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1557\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1557\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/VEKP_VPOBJ.png\" data-orig-size=\"334,403\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"VEKP_VPOBJ\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/VEKP_VPOBJ.png\" class=\"size-medium wp-image-1557 alignnone\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/VEKP_VPOBJ-249x300.png\" alt=\"VEKP_VPOBJ\" width=\"249\" height=\"300\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/VEKP_VPOBJ-249x300.png 249w, https:\/\/oprsteny.cz\/wp-content\/uploads\/VEKP_VPOBJ.png 334w\" sizes=\"auto, (max-width: 249px) 100vw, 249px\" \/><\/a><\/p>\n<p>But what if you need to get information about all HU&#8217;s in all deliveries of one shipment?<\/p>\n<ol>\n<li>You can loop over all deliveries in a shipment and call the standard FM above<\/li>\n<li>You can use custom SQL command<\/li>\n<\/ol>\n<pre lang=\"abap\">DATA:\r\n  iv_tknum TYPE tknum VALUE '1234567',  \"Your shipment number\r\n  lt_venum TYPE TABLE OF venum.         \"table of HU numbers\r\n\r\nSELECT DISTINCT vekp~venum\r\n  INTO TABLE lt_venum\r\n  FROM vttp\r\n  INNER JOIN vekp ON vekp~vpobjkey = vttp~vbeln\r\n                 AND vekp~vpobj    = '01'\r\n  WHERE vttp~tknum = iv_tknum.\r\n\r\n... get further info about selected VENUM's<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this code snippet I&#8217;ll show how you can get info about all the handling units in a shipment delivery.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16,390,389],"tags":[482,483],"class_list":["post-1554","post","type-post","status-publish","format-standard","hentry","category-abap","category-sales-distribution","category-sap","tag-handling-unit","tag-hu_get_hus"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-p4","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1554"}],"version-history":[{"count":3,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1554\/revisions"}],"predecessor-version":[{"id":1558,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1554\/revisions\/1558"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}