{"id":1368,"date":"2015-03-31T09:03:08","date_gmt":"2015-03-31T08:03:08","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=1368"},"modified":"2015-03-31T09:03:08","modified_gmt":"2015-03-31T08:03:08","slug":"abap-select-all-columns-and-inner-join","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=1368","title":{"rendered":"ABAP &#8211; Select * (all columns) and INNER JOIN"},"content":{"rendered":"<p>I fyou want to select all fields of one table and just few fields of another (joined) table, you have to specify all required fields manually. It is NOT possible to write <em>SELECT TAB_1~* TAB_2~FIELD_1 TAB_2~FIELD_2&#8230;<\/em>. In this article I&#8217;ll show how to make this thing easier \ud83d\ude42<!--more--><\/p>\n<p>The selection of all fields (<em>SELECT tabname.*<\/em>) will be done with the following helper method\/form:<\/p>\n<pre lang=\"abap\">TYPES: tt_fields TYPE TABLE OF char300.\r\nFORM add_tabfields_for_selection USING    iv_tabname \r\n                                 CHANGING ct_fields TYPE tt_fields.\r\n\r\nDATA:\r\n    lt_dfies   TYPE dfies_tab,\r\n    lv_tabname TYPE ddobjname.\r\n\r\n  lv_tabname = iv_tabname.\r\n\r\n  CALL FUNCTION 'DDIF_FIELDINFO_GET'\r\n    EXPORTING\r\n      tabname   = lv_tabname\r\n    TABLES\r\n      dfies_tab = lt_dfies.\r\n\r\n* Append each field as line of TABNAME~FIELDNAME of the itab\r\n  LOOP AT lt_dfies ASSIGNING FIELD-SYMBOL(&lt;ls_dfies&gt;).\r\n    APPEND |{ &lt;ls_dfies&gt;-tabname }~{ &lt;ls_dfies&gt;-fieldname }| TO ct_fields.\r\n  ENDLOOP.\r\nENDFORM.<\/pre>\n<p>The real usage of this form might be as in the following code snippet:<\/p>\n<pre lang=\"abap\">TYPES:\r\n  BEGIN OF ts_data.\r\n    INCLUDE TYPE mara.\r\nTYPES:\r\n    maktx   TYPE maktx,\r\n  END OF ts_data,\r\n  tt_data TYPE TABLE OF ts_data.\r\n\r\nDATA:\r\n  lt_fields TYPE tt_fields,\r\n  lt_data   TYPE tt_data.\r\n  \r\n* Add all fields of selected DB table to the SQL selection\r\n  PERFORM add_tabfields_for_selection USING    'MARA'\r\n                                      CHANGING lt_fields.\r\n\r\n* Add subset of fields from MAKT (mat. description)\r\n  APPEND 'MAKT~MAKTX' TO lt_fields.\r\n* ...another fields\r\n\r\n  SELECT (lt_fields)\r\n    INTO CORRESPONDING FIELDS OF TABLE lt_data\r\n    FROM mara\r\n      INNER JOIN makt ON mara~matnr = makt~matnr\r\n    UP TO 5000 ROWS\r\n    WHERE makt~spras = sy-langu.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I fyou want to select all fields of one table and just few fields of another (joined) table, you have to specify all required fields manually. It is NOT possible to write SELECT TAB_1~* TAB_2~FIELD_1 TAB_2~FIELD_2&#8230;. In this article I&#8217;ll &hellip; <a href=\"https:\/\/oprsteny.cz\/?p=1368\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/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,9],"tags":[421],"class_list":["post-1368","post","type-post","status-publish","format-standard","hentry","category-abap","category-development","tag-ddif_fieldinfo_get"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-m4","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1368","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=1368"}],"version-history":[{"count":1,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1368\/revisions"}],"predecessor-version":[{"id":1369,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1368\/revisions\/1369"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}